Skip to content

Commit

Permalink
Merge pull request #197 from plivo/SMS-4994-update-campaign-sdk
Browse files Browse the repository at this point in the history
Update Campaign Ruby SDK
  • Loading branch information
renoldthomas-plivo authored Jan 5, 2023
2 parents 710fcf0 + 92c32ae commit 1fbf684
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [4.34.0](https://github.com/plivo/plivo-ruby/tree/v4.34.0) (2022-12-16)
**10DLC: Update Campaign API**
- Added Update Campaign API

## [4.33.0](https://github.com/plivo/plivo-ruby/tree/v4.33.0) (2022-12-06)
**10DLC: Delete Campaign and Brand API**
- Added Delete campaign and brand API
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
Add this line to your application's Gemfile:

```ruby
gem 'plivo', '>= 4.33.0'
gem 'plivo', '>= 4.34.0'
```

And then execute:
Expand Down
10 changes: 10 additions & 0 deletions lib/plivo/resources/campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ def create(options=nil)
perform_create(options)
end
##
# Update Camapign
def update(campaign_id, options=nil)
valid_param?(:options, options, Hash, true)
if not campaign_id
raise_invalid_request("campaign_id must be provided")
end
action = campaign_id
perform_action_with_identifier(action, 'POST', options)
end
##
# campaign number link
#
def number_link(options=nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/plivo/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Plivo
VERSION = "4.33.0".freeze
VERSION = "4.34.0".freeze
end
25 changes: 25 additions & 0 deletions spec/mocks/campaignUpdateResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"api_id": "f687a17e-0725-11ed-ab02-0242ac110004",
"campaign": {
"brand_id": "BOZ5T2X",
"campaign_id": "CXX",
"mno_metadata": {
"AT&T": {
"tpm": 15
},
"T-Mobile": {
"brand_tier": "SOLE_PROPRIETOR"
},
"US Cellular": {
"tpm": 15
},
"Verizon Wireless": {
"tpm": 15
}
},
"registration_status": "ACTIVE",
"reseller_id": "",
"sub_usecase": "2FA,MARKETING",
"usecase": "STARTER"
}
}
22 changes: 22 additions & 0 deletions spec/resource_campaign_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,28 @@ def to_json_delete(obj)
optout_message: "optoutmessage should be mandatory"
})
end

it 'update campaign' do
contents = File.read(Dir.pwd + '/spec/mocks/campaignUpdateResponse.json')
mock(200, JSON.parse(contents))
response = to_json(@api.campaign
.update("CXX",
params ={
sample1: "sample message 1 should be 20 minimum character",
}
)
)

contents = JSON.parse(contents)

expect(JSON.parse(response))
.to eql(contents)
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/CXX/',
method: 'POST',
data: {
sample1: "sample message 1 should be 20 minimum character"
})
end
it 'number_link campaign' do
contents = File.read(Dir.pwd + '/spec/mocks/campaignNumberLinkUnlinkResponse.json')
mock(200, JSON.parse(contents))
Expand Down

0 comments on commit 1fbf684

Please sign in to comment.