diff --git a/applications.go b/applications.go index 4761777..0e16dc3 100644 --- a/applications.go +++ b/applications.go @@ -23,6 +23,23 @@ type Application struct { // Additional fields for Modify calls DefaultNumberApp bool `json:"default_number_app,omitempty" url:"default_number_app,omitempty"` DefaultEndpointApp bool `json:"default_endpoint_app,omitempty" url:"default_endpoint_app,omitempty"` + + //log incoming messages. Default is true + LogIncomingMessage *bool `json:"log_incoming_message,omitempty" url:"log_incoming_message,omitempty"` +} + +// SetLogIncomingMessage sets the field value with the appropriate boolean value. +func (a *Application) SetLogIncomingMessage(value bool) *Application { + field := value + a.LogIncomingMessage = &field + return a +} + +func (a *Application) GetLogIncomingMessage() bool { + if a.LogIncomingMessage != nil { + return *a.LogIncomingMessage + } + return false } //TODO Verify against docs @@ -45,6 +62,23 @@ type ApplicationCreateParams struct { // Additional fields for Modify calls DefaultNumberApp bool `json:"default_number_app,omitempty" url:"default_number_app,omitempty"` DefaultEndpointApp bool `json:"default_endpoint_app,omitempty" url:"default_endpoint_app,omitempty"` + + //log incoming messages. Default is true + LogIncomingMessage *bool `json:"log_incoming_message,omitempty" url:"default_number_app,omitempty"` +} + +// SetLogIncomingMessage sets the field value with the appropriate boolean value. +func (acp *ApplicationCreateParams) SetLogIncomingMessage(value bool) *ApplicationCreateParams { + field := value + acp.LogIncomingMessage = &field + return acp +} + +func (acp *ApplicationCreateParams) GetLogIncomingMessage() bool { + if acp.LogIncomingMessage != nil { + return *acp.LogIncomingMessage + } + return false } // TODO Check against docs diff --git a/applications_test.go b/applications_test.go index 5d56baa..ebf0fa4 100644 --- a/applications_test.go +++ b/applications_test.go @@ -2,8 +2,9 @@ package plivo import ( "errors" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestApplicationService_Create(t *testing.T) { diff --git a/fixtures/applicationGetResponse.json b/fixtures/applicationGetResponse.json index cda9d05..87bf352 100644 --- a/fixtures/applicationGetResponse.json +++ b/fixtures/applicationGetResponse.json @@ -16,5 +16,6 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/20468599130939380/", "sip_uri": "sip:20468599130939380@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": true } diff --git a/fixtures/applicationListResponse.json b/fixtures/applicationListResponse.json index 99f2c8a..bd3a379 100644 --- a/fixtures/applicationListResponse.json +++ b/fixtures/applicationListResponse.json @@ -25,7 +25,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/20468599130939380/", "sip_uri": "sip:20468599130939380@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": true }, { "answer_method": "POST", @@ -44,7 +45,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/13094892674577059/", "sip_uri": "sip:13094892674577059@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": false }, { "answer_method": "POST", @@ -63,7 +65,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/64529074997228907/", "sip_uri": "sip:64529074997228907@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": true }, { "answer_method": "GET", @@ -82,7 +85,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30042999414609341/", "sip_uri": "sip:30042999414609341@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": true }, { "answer_method": "GET", @@ -101,7 +105,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30042349822904887/", "sip_uri": "sip:30042349822904887@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": true }, { "answer_method": "GET", @@ -120,7 +125,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30041373335801898/", "sip_uri": "sip:30041373335801898@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": true }, { "answer_method": "POST", @@ -139,7 +145,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30040535577211472/", "sip_uri": "sip:30040535577211472@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": true }, { "answer_method": "GET", @@ -158,7 +165,8 @@ "public_uri": false, "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30039778631346811/", "sip_uri": "sip:30039778631346811@app.plivo.com", - "sub_account": null + "sub_account": null, + "log_incoming_message": false } ] } diff --git a/plivoclient.go b/plivoclient.go index e3a8a9b..bcdeb82 100644 --- a/plivoclient.go +++ b/plivoclient.go @@ -11,8 +11,9 @@ import ( "os" "time" - "github.com/google/go-querystring/query" "runtime" + + "github.com/google/go-querystring/query" ) const baseUrlString = "https://api.plivo.com/"