diff --git a/calls.go b/calls.go index 50dbe89..3f87612 100644 --- a/calls.go +++ b/calls.go @@ -278,22 +278,6 @@ type CallStreamGetSpecific struct { StreamID string `json:"stream_id" url:"stream_id"` } -type VoiceInteractionResponse struct { - StartTime string `json:"start_time,omitempty" url:"start_time,omitempty"` - EndTime string `json:"end_time,omitempty" url:"end_time,omitempty"` - FirstPartyResourceUrl string `json:"first_party_resource_url,omitempty" url:"first_party_resource_url,omitempty"` - SecondPartyResourceUrl string `json:"second_party_resource_url,omitempty" url:"second_party_resource_url,omitempty"` - FirstPartyStatus string `json:"first_party_status,omitempty" url:"first_party_status,omitempty"` - SecondPartyStatus string `json:"second_party_status,omitempty" url:"second_party_status,omitempty"` - Type string `json:"type,omitempty" url:"type,omitempty"` - TotalCallAmount float64 `json:"total_call_amount,omitempty" url:"total_call_amount,omitempty"` - CallBilledDuration int `json:"call_billed_duration,omitempty" url:"call_billed_duration,omitempty"` - RecordingResourceUrl string `json:"recording_resource_url,omitempty" url:"recording_resource_url,omitempty"` - AuthID string `json:"auth_id,omitempty" url:"auth_id,omitempty"` - TotalCallCount int `json:"total_call_count" url:"total_call_count"` - Duration float64 `json:"duration" url:"duration"` -} - func (service *CallService) List(params CallListParams) (response *CallListResponse, err error) { req, err := service.client.NewRequest("GET", params, "Call") if err != nil { diff --git a/calls_test.go b/calls_test.go index d9b5522..d943691 100644 --- a/calls_test.go +++ b/calls_test.go @@ -366,101 +366,3 @@ func TestCallService_GetAllStreams(t *testing.T) { assertRequest(t, "GET", "Call/%s/Stream", CallID) } - -func TestCallService_CreateMaskingSession(t *testing.T) { - expectResponse("createMaskingSessionResponse.json", 200) - - if _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{}); err != nil { - panic(err) - } - - cl := client.httpClient - client.httpClient = nil - _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{}) - if err == nil { - client.httpClient = cl - panic(errors.New("error expected")) - } - client.httpClient = cl - - assertRequest(t, "POST", "Masking/Session") -} - -func TestCallService_DeleteMaskingSession(t *testing.T) { - expectResponse("deleteMaskingSessionResponse.json", 204) - SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71" - - if _, err := client.MaskingSession.DeleteMaskingSession(SessionUuid); err != nil { - panic(err) - } - - cl := client.httpClient - client.httpClient = nil - _, err := client.MaskingSession.DeleteMaskingSession(SessionUuid) - if err == nil { - client.httpClient = cl - panic(errors.New("error expected")) - } - client.httpClient = cl - - assertRequest(t, "DELETE", "Masking/Session/%s", SessionUuid) -} - -func TestCallService_GetMaskingSession(t *testing.T) { - expectResponse("getMaskingSessionResponse.json", 200) - SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71" - - if _, err := client.MaskingSession.GetMaskingSession(SessionUuid); err != nil { - panic(err) - } - - cl := client.httpClient - client.httpClient = nil - _, err := client.MaskingSession.GetMaskingSession(SessionUuid) - if err == nil { - client.httpClient = cl - panic(errors.New("error expected")) - } - client.httpClient = cl - - assertRequest(t, "GET", "Masking/Session/%s", SessionUuid) -} - -func TestCallService_updateMaskingSession(t *testing.T) { - expectResponse("updateMaskingSessionResponse.json", 204) - SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71" - - if _, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid); err != nil { - panic(err) - } - - cl := client.httpClient - client.httpClient = nil - _, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid) - if err == nil { - client.httpClient = cl - panic(errors.New("error expected")) - } - client.httpClient = cl - - assertRequest(t, "POST", "Masking/Session/%s", SessionUuid) -} - -func TestCallService_ListMaskingSession(t *testing.T) { - expectResponse("listMaskingSessionResponse.json", 204) - - if _, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{}); err != nil { - panic(err) - } - - cl := client.httpClient - client.httpClient = nil - _, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{}) - if err == nil { - client.httpClient = cl - panic(errors.New("error expected")) - } - client.httpClient = cl - - assertRequest(t, "GET", "Masking/Session") -} diff --git a/maskingsession.go b/maskingsession.go index 494a646..4503ae3 100644 --- a/maskingsession.go +++ b/maskingsession.go @@ -89,6 +89,22 @@ type ListSessionFilterParams struct { Offset int64 `json:"offset,omitempty" url:"offset,omitempty"` } +type VoiceInteractionResponse struct { + StartTime string `json:"start_time,omitempty" url:"start_time,omitempty"` + EndTime string `json:"end_time,omitempty" url:"end_time,omitempty"` + FirstPartyResourceUrl string `json:"first_party_resource_url,omitempty" url:"first_party_resource_url,omitempty"` + SecondPartyResourceUrl string `json:"second_party_resource_url,omitempty" url:"second_party_resource_url,omitempty"` + FirstPartyStatus string `json:"first_party_status,omitempty" url:"first_party_status,omitempty"` + SecondPartyStatus string `json:"second_party_status,omitempty" url:"second_party_status,omitempty"` + Type string `json:"type,omitempty" url:"type,omitempty"` + TotalCallAmount float64 `json:"total_call_amount,omitempty" url:"total_call_amount,omitempty"` + CallBilledDuration int `json:"call_billed_duration,omitempty" url:"call_billed_duration,omitempty"` + RecordingResourceUrl string `json:"recording_resource_url,omitempty" url:"recording_resource_url,omitempty"` + AuthID string `json:"auth_id,omitempty" url:"auth_id,omitempty"` + TotalCallCount int `json:"total_call_count" url:"total_call_count"` + Duration float64 `json:"duration" url:"duration"` +} + type CreateMaskingSessionResponse struct { ApiID string `json:"api_id,omitempty" url:"api_id,omitempty"` SessionUUID string `json:"session_uuid,omitempty" url:"session_uuid,omitempty"` diff --git a/maskingsession_test.go b/maskingsession_test.go new file mode 100644 index 0000000..d6437b2 --- /dev/null +++ b/maskingsession_test.go @@ -0,0 +1,104 @@ +package plivo + +import ( + "errors" + "testing" +) + +func TestCallService_CreateMaskingSession(t *testing.T) { + expectResponse("createMaskingSessionResponse.json", 200) + + if _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{}); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{}) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl + + assertRequest(t, "POST", "Masking/Session") +} + +func TestCallService_DeleteMaskingSession(t *testing.T) { + expectResponse("deleteMaskingSessionResponse.json", 204) + SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71" + + if _, err := client.MaskingSession.DeleteMaskingSession(SessionUuid); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.MaskingSession.DeleteMaskingSession(SessionUuid) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl + + assertRequest(t, "DELETE", "Masking/Session/%s", SessionUuid) +} + +func TestCallService_GetMaskingSession(t *testing.T) { + expectResponse("getMaskingSessionResponse.json", 200) + SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71" + + if _, err := client.MaskingSession.GetMaskingSession(SessionUuid); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.MaskingSession.GetMaskingSession(SessionUuid) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl + + assertRequest(t, "GET", "Masking/Session/%s", SessionUuid) +} + +func TestCallService_updateMaskingSession(t *testing.T) { + expectResponse("updateMaskingSessionResponse.json", 204) + SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71" + + if _, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl + + assertRequest(t, "POST", "Masking/Session/%s", SessionUuid) +} + +func TestCallService_ListMaskingSession(t *testing.T) { + expectResponse("listMaskingSessionResponse.json", 204) + + if _, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{}); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{}) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl + + assertRequest(t, "GET", "Masking/Session") +}