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 log_incoming_message field for Application to control message red… #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion applications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion fixtures/applicationGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/20468599130939380/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": true
}
24 changes: 16 additions & 8 deletions fixtures/applicationListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/20468599130939380/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": true
},
{
"answer_method": "POST",
Expand All @@ -44,7 +45,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/13094892674577059/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": false
},
{
"answer_method": "POST",
Expand All @@ -63,7 +65,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/64529074997228907/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": true
},
{
"answer_method": "GET",
Expand All @@ -82,7 +85,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30042999414609341/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": true
},
{
"answer_method": "GET",
Expand All @@ -101,7 +105,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30042349822904887/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": true
},
{
"answer_method": "GET",
Expand All @@ -120,7 +125,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30041373335801898/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": true
},
{
"answer_method": "POST",
Expand All @@ -139,7 +145,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30040535577211472/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": true
},
{
"answer_method": "GET",
Expand All @@ -158,7 +165,8 @@
"public_uri": false,
"resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Application/30039778631346811/",
"sip_uri": "sip:[email protected]",
"sub_account": null
"sub_account": null,
"log_incoming_message": false
}
]
}
3 changes: 2 additions & 1 deletion plivoclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down