Skip to content

Commit

Permalink
Merge pull request #195 from plivo/SMS-4444-Brand-Usecase
Browse files Browse the repository at this point in the history
Brand Usecase
  • Loading branch information
renoldthomas-plivo authored Nov 9, 2022
2 parents 7161488 + ffe830b commit 712688d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 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.32.0](https://github.com/plivo/plivo-ruby/tree/v4.32.0) (2022-11-03)
**10DLC: Brand Usecase API**
- Added Brand Usecase API

## [4.31.0](https://github.com/plivo/plivo-ruby/tree/v4.31.0) (2022-10-14)
**Adding new attributes to Account PhoneNumber object**
-Added 3 new keys to AccountPhoneNumber object:`tendlc_registration_status`, `tendlc_campaign_id` and `toll_free_sms_verification` (https://www.plivo.com/docs/numbers/api/account-phone-number#the-accountphonenumber-object)
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.31.0'
gem 'plivo', '>= 4.32.0'
```

And then execute:
Expand Down
9 changes: 9 additions & 0 deletions lib/plivo/resources/brand.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ def create(options=nil)
end
perform_create(options)
end

##
# Get BrandUsecase
# @param [String] brand_id
def get_usecases(brand_id)
valid_param?(:brand_id, brand_id, [String, Symbol], true)
identifier = brand_id + '/usecases'
perform_action_with_identifier(identifier, 'GET', nil)
end
end
end
end
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.31.0".freeze
VERSION = "4.32.0".freeze
end
11 changes: 11 additions & 0 deletions spec/mocks/brandGetUsecasesResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"api_id": "dbc70630-3296-11ed-9b52-0242ac110004",
"use_cases": [
{
"name": "Starter",
"code": "STARTER",
"details": "Low cost campaign type designed for individuals and small businesses"
}
],
"brand_id": "BPL3KN9"
}
30 changes: 26 additions & 4 deletions spec/resource_brand_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ def to_json_create(obj)
brand_id: obj.brand_id,
message: obj.message
}.reject { |_, v| v.nil? }.to_json
end
end
def to_json_brand_usecase(obj)
puts obj
{
api_id: obj.api_id,
brand_id: obj.brand_id,
use_cases: obj.use_cases
}.reject { |_, v| v.nil? }.to_json
end
it 'get brand' do
contents = File.read(Dir.pwd + '/spec/mocks/brandGetResponse.json')
mock(200, JSON.parse(contents))
Expand Down Expand Up @@ -106,9 +114,9 @@ def to_json_create(obj)
resellerID: "87868787788"
}
))

contents = JSON.parse(contents)

expect(JSON.parse(response))
.to eql(contents)
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Brand/',
Expand Down Expand Up @@ -140,4 +148,18 @@ def to_json_create(obj)
resellerID: "87868787788"
})
end
end
it 'get brand usecase' do
contents = File.read(Dir.pwd + '/spec/mocks/brandGetUsecasesResponse.json')
mock(200, JSON.parse(contents))
response = @api.brand
.get_usecases(
'BPL3KN9'
)
expect(JSON.parse(to_json_brand_usecase(response)))
.to eql(JSON.parse(contents))
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Brand/'\
'BPL3KN9/usecases/',
method: 'GET',
data: nil)
end
end

0 comments on commit 712688d

Please sign in to comment.