Skip to content

Commit

Permalink
Merge pull request #18 from kunal-plivo/filter-live-calls
Browse files Browse the repository at this point in the history
live calls filtering by from, to number and call direction
  • Loading branch information
Sachin Kulshrestha authored Oct 31, 2018
2 parents a3dc01e + 7b960f6 commit acffaa3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ type CallListParams struct {
Offset int64 `json:"offset:omitempty" url:"offset:omitempty"`
}

type LiveCallFilters struct {
CallDirection string `json:"call_direction,omitempty" url:"call_direction,omitempty"`
FromNumber string `json:"from_number,omitempty" url:"from_number,omitempty"`
ToNumber string `json:"to_number,omitempty" url:"to_number,omitempty"`
Status string `json:"status,omitempty" url:"status,omitempty" default:"live"`
}

type CallListResponse struct {
ApiID string `json:"api_id" url:"api_id"`
Meta *Meta `json:"meta" url:"meta"`
Expand Down Expand Up @@ -254,10 +261,9 @@ func (service *LiveCallService) Get(LiveCallId string) (response *LiveCall, err
return
}

func (service *LiveCallService) IDList() (response *LiveCallIDListResponse, err error) {
req, err := service.client.NewRequest("GET", struct {
Status string `json:"status" url:"status"`
}{"live"}, "Call")
func (service *LiveCallService) IDList(params LiveCallFilters) (response *LiveCallIDListResponse, err error) {
params.Status = "live"
req, err := service.client.NewRequest("GET", params, "Call")
if err != nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions calls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ func TestCallService_Delete(t *testing.T) {
func TestLiveCallService_List(t *testing.T) {
expectResponse("LiveCallListGetResponse.json", 200)

if _, err := client.LiveCalls.IDList(); err != nil {
if _, err := client.LiveCalls.IDList(LiveCallFilters{}); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.LiveCalls.IDList()
_, err := client.LiveCalls.IDList(LiveCallFilters{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
Expand Down

0 comments on commit acffaa3

Please sign in to comment.