Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logic to handle invalid_numbers for BULK SMS #40

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [4.1.1] (https://github.com/plivo/plivo-go/tree/v4.1.1) (2019-08-08)
- Add logic to handle invalid numbers for bulk SMS
- Add test case to handle invalid numbers for bulk SMS
- Add missing params for Make a call

## [4.1.0](https://github.com/plivo/plivo-go/tree/v4.1.0) (2019-03-12)
- Add PHLO support
- Add Multi-party call triggers
11 changes: 11 additions & 0 deletions baseclient.go
Original file line number Diff line number Diff line change
@@ -97,6 +97,17 @@ func (client *BaseClient) ExecuteRequest(request *http.Request, body interface{}

data, err := ioutil.ReadAll(response.Body)
if err == nil && data != nil && len(data) > 0 {
v := reflect.ValueOf(body).Elem().FieldByName("StatusCode")
//fmt.Println("fields: ", reflect.ValueOf(body).Elem().NumField())
ptr := v.Addr().Interface().(*int)
*ptr = response.StatusCode

// origin := body.(*MessageCreateResponseBody)
// origin.StatusCode = response.StatusCode
// fmt.Printf("%v\n",origin.StatusCode)



if response.StatusCode >= 200 && response.StatusCode < 300 {
if body != nil {
err = json.Unmarshal(data, body)
29 changes: 23 additions & 6 deletions calls.go
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ type QueuedCallService struct {
}

type Call struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
FromNumber string `json:"from_number,omitempty" url:"from_number,omitempty"`
ToNumber string `json:"to_number,omitempty" url:"to_number,omitempty"`
AnswerURL string `json:"answer_url,omitempty" url:"answer_url,omitempty"`
@@ -32,6 +33,7 @@ type Call struct {
}

type LiveCall struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
From string `json:"from,omitempty" url:"from,omitempty"`
To string `json:"to,omitempty" url:"to,omitempty"`
AnswerURL string `json:"answer_url,omitempty" url:"answer_url,omitempty"`
@@ -43,6 +45,7 @@ type LiveCall struct {
}

type QueuedCall struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
From string `json:"from,omitempty" url:"from,omitempty"`
To string `json:"to,omitempty" url:"to,omitempty"`
Status string `json:"call_status,omitempty" url:"call_status,omitempty"`
@@ -54,11 +57,13 @@ type QueuedCall struct {
}

type LiveCallIDListResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
APIID string `json:"api_id" url:"api_id"`
Calls []string `json:"calls" url:"calls"`
}

type QueuedCallIDListResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
APIID string `json:"api_id" url:"api_id"`
Calls []string `json:"calls" url:"calls"`
}
@@ -78,17 +83,21 @@ type CallCreateParams struct {
FallbackMethod string `json:"fallback_method,omitempty" url:"fallback_method,omitempty"`
CallerName string `json:"caller_name,omitempty" url:"caller_name,omitempty"`
SendDigits string `json:"send_digits,omitempty" url:"send_digits,omitempty"`
SendOnPreanswer bool `json:"send_on_preanswer,omitempty" url:"send_on_preanswer,omitempty"`
SendOnPreanswer string `json:"send_on_preanswer,omitempty" url:"send_on_preanswer,omitempty"`
TimeLimit int64 `json:"time_limit,omitempty" url:"time_limit,omitempty"`
HangupOnRing int64 `json:"hangup_on_ring,omitempty" url:"hangup_on_ring,omitempty"`
MachineDetection string `json:"machine_detection,omitempty" url:"machine_detection,omitempty"`
MachineDetectionTime int64 `json:"machine_detection_time,omitempty" url:"machine_detection_time,omitempty"`
MachineDetectionMethod string `json:"machine_detection_method,omitempty" url:"machine_detection_method,omitempty"`
SipHeaders string `json:"sip_headers,omitempty" url:"sip_headers,omitempty"`
RingTimeout int64 `json:"ring_timeout,omitempty" url:"ring_timeout,omitempty"`
ParentCallUUID string `json:"parent_call_uuid,omitempty" url:"parent_call_uuid,omitempty"`
ErrorIfParentNotFound string `json:"error_if_parent_not_found,omitempty" url:"error_if_parent_not_found,omitempty"`
}

// Stores response for making a call.
type CallCreateResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
Message string `json:"message" url:"message"`
ApiID string `json:"api_id" url:"api_id"`
AppID string `json:"app_id" url:"app_id"`
@@ -102,10 +111,11 @@ type CallListParams struct {
FromNumber string `json:"from_number,omitempty" url:"from_number,omitempty"`
ToNumber string `json:"to_number,omitempty" url:"to_number,omitempty"`
ParentCallUUID string `json:"parent_call_uuid,omitempty" url:"parent_call_uuid,omitempty"`
EndTimeEquals string `json:"end_time,omitempty" url:"end_time,omitempty"`
HangupCauseCode int64 `json:"hangup_cause_code,omitempty" url:"hangup_cause_code,omitempty"`
HangupSource string `json:"hangup_source,omitempty" url:"hangup_source,omitempty"`

EndTimeEquals string `json:"end_time,omitempty" url:"end_time,omitempty"`

EndTimeLessThan string `json:"end_time__lt,omitempty" url:"end_time__lt,omitempty"`

EndTimeGreaterThan string `json:"end_time__gt,omitempty" url:"end_time__gt,omitempty"`
@@ -123,6 +133,7 @@ type CallListParams struct {
BillDurationLessOrEqual string `json:"bill_duration__lte,omitempty" url:"bill_duration__lte,omitempty"`

BillDurationGreaterOrEqual string `json:"bill_duration__gte,omitempty" url:"bill_duration__gte,omitempty"`

Limit int64 `json:"limit,omitempty" url:"limit,omitempty"`
Offset int64 `json:"offset,omitempty" url:"offset,omitempty"`
}
@@ -135,6 +146,7 @@ type LiveCallFilters struct {
}

type CallListResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
ApiID string `json:"api_id" url:"api_id"`
Meta *Meta `json:"meta" url:"meta"`
Objects []*Call `json:"objects" url:"objects"`
@@ -149,6 +161,7 @@ type CallUpdateParams struct {
}

type CallUpdateResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
ApiID string `json:"api_id" url:"api_id"`
Message string `json:"message" url:"message"`
}
@@ -164,6 +177,7 @@ type CallRecordParams struct {
}

type CallRecordResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
Message string `json:"message,omitempty" url:"message,omitempty"`
URL string `json:"url,omitempty" url:"url,omitempty"`
APIID string `json:"api_id,omitempty" url:"api_id,omitempty"`
@@ -172,27 +186,29 @@ type CallRecordResponse struct {

type CallPlayParams struct {
URLs string `json:"urls" url:"urls"`
Length string `json:"length,omitempty" url:"length,omitempty"`
Length int `json:"length,omitempty" url:"length,omitempty"`
Legs string `json:"legs,omitempty" url:"legs,omitempty"`
Loop bool `json:"loop,omitempty" url:"loop,omitempty"`
Mix bool `json:"mix,omitempty" url:"mix,omitempty"`
}

type CallPlayResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
Message string `json:"message,omitempty" url:"message,omitempty"`
ApiID string `json:"api_id,omitempty" url:"api_id,omitempty"`
}

type CallSpeakParams struct {
Text string `json:"text" url:"text"`
Voice string `json:"length,omitempty" url:"length,omitempty"`
Voice string `json:”voice,omitempty" url:"voice,omitempty"`
Language string `json:"language,omitempty" url:"language,omitempty"`
Legs string `json:"legs,omitempty" url:"legs,omitempty"`
Loop bool `json:"loop,omitempty" url:"loop,omitempty"`
Mix bool `json:"mix,omitempty" url:"mix,omitempty"`
Loop string `json:"loop,omitempty" url:"loop,omitempty"`
Mix string `json:"mix,omitempty" url:"mix,omitempty"`
}

type CallSpeakResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
Message string `json:"message,omitempty" url:"message,omitempty"`
ApiID string `json:"api_id,omitempty" url:"api_id,omitempty"`
}
@@ -203,6 +219,7 @@ type CallDTMFParams struct {
}

type CallDTMFResponseBody struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
Message string `json:"message,omitempty" url:"message,omitempty"`
ApiID string `json:"api_id,omitempty" url:"api_id,omitempty"`
}
8 changes: 7 additions & 1 deletion endpoints.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ type EndpointService struct {
}

type Endpoint struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
Alias string `json:"alias,omitempty" url:"alias,omitempty"`
EndpointID string `json:"endpoint_id,omitempty" url:"endpoint_id,omitempty"`
Password string `json:"password,omitempty" url:"password,omitempty"`
@@ -29,18 +30,23 @@ type EndpointCreateParams struct {
}

type EndpointCreateResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
BaseResponse
Alias string `json:"alias,omitempty" url:"alias,omitempty"`
EndpointID string `json:"endpoint_id,omitempty" url:"endpoint_id,omitempty"`
Username string `json:"username,omitempty" url:"username,omitempty"`
}

type EndpointListResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
BaseListResponse
Objects []*Endpoint `json:"objects" url:"objects"`
}

type EndpointUpdateResponse BaseResponse
type EndpointUpdateResponse struct{
StatusCode int `json:"StatusCode" url:"StatusCode"`
BaseResponse
}

type EndpointListParams struct {
Limit int `url:"limit,omitempty"`
3 changes: 3 additions & 0 deletions fixtures/messageSendResponse.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,8 @@
"message": "message(s) queued",
"message_uuid": [
"5b40a428-bfc7-4daf-9d06-726c558bf3b8"
],
"invalid_number": [
"919012345678"
]
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/plivo/plivo-go

go 1.12
2 changes: 2 additions & 0 deletions messages.go
Original file line number Diff line number Diff line change
@@ -34,10 +34,12 @@ type Message struct {

// Stores response for ending a message.
type MessageCreateResponseBody struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
Message string `json:"message" url:"message"`
ApiID string `json:"api_id" url:"api_id"`
MessageUUID []string `json:"message_uuid" url:"message_uuid"`
Error string `json:"error" url:"error"`
InvalidNumber []string `json:"invalid_number, omitempty" url:"invalid_number,omitempty"`
}

type MessageList struct {
2 changes: 2 additions & 0 deletions recordings.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ type RecordingService struct {
}

type Recording struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
AddTime string `json:"add_time,omitempty" url:"add_time,omitempty"`
CallUUID string `json:"call_uuid,omitempty" url:"call_uuid,omitempty"`
RecordingID string `json:"recording_id,omitempty" url:"recording_id,omitempty"`
@@ -36,6 +37,7 @@ type RecordingListParams struct {
}

type RecordingListResponse struct {
StatusCode int `json:"StatusCode" url:"StatusCode"`
ApiID string `json:"api_id" url:"api_id"`
Meta *Meta `json:"meta" url:"meta"`
Objects []*Recording `json:"objects" url:"objects"`