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

ruby sdk changes for cnam storage #219

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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [4.46.0](https://github.com/plivo/plivo-ruby/tree/v4.46.0) (2023-06-27)
**Feature - CNAM**
- Added New Param `cnam` in to the response of the [list all numbers API], [list single number API]
- Added `cnam` parameter to buy number[Buy a Phone Number] to configure CNAM while buying a US number
- Added `callback_url` parameter to buy number[Buy a Phone Number] to configure CNAM callback url while buying a US number
- Added `callback_method` parameter to buy number[Buy a Phone Number] to configure CNAM callback method while buying a US number
- Added `cnam` parameter to update number[Update an account phone number] to configure CNAM while updating a US number
- Added `callback_url` parameter to update number[Update an account phone number] to configure CNAM callback url while updating a US number
- Added `callback_method` parameter to update number[Update an account phone number] to configure CNAM callback method while updating a US number


## [4.45.0](https://github.com/plivo/plivo-ruby/tree/v4.45.0) (2023-05-02)
**Feature - CNAM Lookup**
- Added New Param `cnam_lookup` in to the response of the [list all numbers API], [list single number 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.45.0'
gem 'plivo', '>= 4.46.0'
```

And then execute:
Expand Down
20 changes: 14 additions & 6 deletions lib/plivo/resources/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ def initialize(client, options = nil)
super
end

def buy(app_id = nil, verification_info = nil, cnam_lookup = nil)
def buy(app_id = nil, verification_info = nil, cnam_lookup = nil, cnam = nil, callback_url = nil, callback_method = nil)
params = {}
params[:app_id] = app_id unless app_id.nil?
params[:verification_info] = verification_info unless verification_info.nil?
params[:cnam_lookup] = cnam_lookup unless cnam_lookup.nil?
params[:cnam] = cnam unless cnam.nil?
params[:callback_url] = callback_url unless callback_url.nil?
params[:callback_method] = callback_method unless callback_method.nil?
perform_action(nil, 'POST', params, true)
end

Expand Down Expand Up @@ -119,10 +122,10 @@ def each(country_iso)
end
end

def buy(number, app_id = nil, verification_info = nil, cnam_lookup = nil)
def buy(number, app_id = nil, verification_info = nil, cnam_lookup = nil, cnam = nil, callback_url = nil, callback_method = nil)
valid_param?(:number, number, [Integer, String, Symbol], true)
PhoneNumber.new(@_client,
resource_id: number).buy(app_id, verification_info, cnam_lookup)
resource_id: number).buy(app_id, verification_info, cnam_lookup, cnam, callback_url, callback_method)
end
end

Expand All @@ -143,7 +146,7 @@ def update(options = nil)
params[:subaccount] = options[:subaccount]
end

%i[alias app_id cnam_lookup].each do |param|
%i[alias app_id cnam_lookup cnam callback_url callback_method].each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], true)
params[param] = options[param]
Expand Down Expand Up @@ -185,7 +188,8 @@ def to_s
tendlc_registration_status: @tendlc_registration_status,
toll_free_sms_verification: @toll_free_sms_verification,
renewal_date: @renewal_date,
cnam_lookup: @cnam_lookup
cnam_lookup: @cnam_lookup,
cnam: @cnam
}.to_s
end
end
Expand Down Expand Up @@ -231,14 +235,15 @@ def get(number)
# @option options [String] :cnam_lookup The Cnam Lookup Configuration associated with that number. The following values are valid:
# - enabled - Returns the list of numbers for which Cnam Lookup configuration is enabled
# - disabled - Returns the list of numbers for which Cnam Lookup configuration is disabled
# @option options [String] :cnam The Cnam Configuration associated with that number.
def list(options = nil)
return perform_list if options.nil?

valid_param?(:options, options, Hash, true)

params = {}

%i[number_startswith subaccount alias tendlc_campaign_id tendlc_registration_status toll_free_sms_verification renewal_date renewal_date__lt renewal_date__lte renewal_date__gt renewal_date__gte cnam_lookup].each do |param|
%i[number_startswith subaccount alias tendlc_campaign_id tendlc_registration_status toll_free_sms_verification renewal_date renewal_date__lt renewal_date__lte renewal_date__gt renewal_date__gte cnam_lookup cnam].each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], true)
params[param] = options[param]
Expand Down Expand Up @@ -330,6 +335,9 @@ def add_number(numbers, carrier, region, options = nil)
# @option options [String] :app_id The application id of the application that is to be linked.
# @option options [String] :subaccount The auth_id of the subaccount to which this number should be added. This can only be performed by a main account holder.
# @option options [String] :cnam_lookup The Cnam Lookup configuration to enable/disable Cnam Lookup
# @option options [String] :cnam The Cnam configuration value.
# @option options [String] :callback_url The Cnam callback url configuration .
# @option options [String] :callback_method The Cnam callback method configuration.
def update(number, options = nil)
valid_param?(:number, number, [String, Symbol], true)
Number.new(@_client,
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.45.0".freeze
VERSION = "4.46.0".freeze
end
3 changes: 2 additions & 1 deletion spec/mocks/numberGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
}
9 changes: 6 additions & 3 deletions spec/mocks/numberListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
},
{
"added_on": "2013-01-01",
Expand All @@ -48,7 +49,8 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
},
{
"added_on": "2013-03-25",
Expand All @@ -69,7 +71,8 @@
"tendlc_registration_status": null,
"toll_free_sms_verification": "verified",
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
}
]
}
3 changes: 2 additions & 1 deletion spec/resource_numbers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def to_json(number)
tendlc_registration_status: number.tendlc_registration_status,
toll_free_sms_verification: number.toll_free_sms_verification,
renewal_date: number.renewal_date,
cnam_lookup: number.cnam_lookup
cnam_lookup: number.cnam_lookup,
cnam: number.cnam
}.to_json
end

Expand Down