Skip to content

Commit

Permalink
PHONUM-2816 (#218)
Browse files Browse the repository at this point in the history
* changes for cnam lookup

* bump version

---------

Co-authored-by: kalyan-plivo <[email protected]>
  • Loading branch information
kapilp93 and kalyan-plivo committed Jun 2, 2023
1 parent 9def7bb commit 21d7bc6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [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]
- Added `cnam_lookup` filter to AccountPhoneNumber - list all my numbers API.
- Added `cnam_lookup` parameter to buy number[Buy a Phone Number] to configure CNAM Lookup while buying a US number
- Added `cnam_lookup` parameter to update number[Update an account phone number] to configure CNAM Lookup while buying a US number


## [4.44.0](https://github.com/plivo/plivo-ruby/tree/v4.38.2) (2023-03-16)
**Feature : Added new param in getCallDetail api**
- From now on we can see CNAM(Caller_id name) details at CDR level.
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.44.0'
gem 'plivo', '>= 4.45.0'
```

And then execute:
Expand Down
2 changes: 1 addition & 1 deletion lib/plivo/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def process_response(method, response)
raise Exceptions::PlivoRESTError, "Resource at #{response[:url]} "\
'couldn\'t be deleted'
end
elsif !([200, 201, 202, 204, 207].include? response[:status])
elsif !([200, 201, 202, 204, 207, 206].include? response[:status])
raise Exceptions::PlivoRESTError, "Received #{response[:status]} for #{method}"
end
@@voice_retry_count = 0
Expand Down
18 changes: 12 additions & 6 deletions lib/plivo/resources/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ def initialize(client, options = nil)
super
end

def buy(app_id = nil, verification_info = nil)
def buy(app_id = nil, verification_info = nil, cnam_lookup = 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?
perform_action(nil, 'POST', params, true)
end

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

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

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

%i[alias app_id].each do |param|
%i[alias app_id cnam_lookup].each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], true)
params[param] = options[param]
Expand Down Expand Up @@ -183,7 +184,8 @@ def to_s
tendlc_campaign_id: @tendlc_campaign_id,
tendlc_registration_status: @tendlc_registration_status,
toll_free_sms_verification: @toll_free_sms_verification,
renewal_date: @renewal_date
renewal_date: @renewal_date,
cnam_lookup: @cnam_lookup
}.to_s
end
end
Expand Down Expand Up @@ -226,14 +228,17 @@ def get(number)
# @option options [String] :renewal_date__lte Returns phone numbers that will be renewed on or before the specified date. Format: YYYY-MM-DD
# @option options [String] :renewal_date__gt Returns phone numbers that will be renewed after the specified date. Format: YYYY-MM-DD
# @option options [String] :renewal_date__gte Returns phone numbers that will be renewed on or after the specified date. Format: YYYY-MM-DD
# @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
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].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].each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], true)
params[param] = options[param]
Expand Down Expand Up @@ -324,6 +329,7 @@ def add_number(numbers, carrier, region, options = nil)
# @option options [String] :alias The textual name given to the number.
# @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
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.44.0".freeze
VERSION = "4.45.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 @@ -17,5 +17,6 @@
"tendlc_campaign_id": "ACB1234",
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10"
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
}
9 changes: 6 additions & 3 deletions spec/mocks/numberListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"tendlc_campaign_id": "ACB1234",
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10"
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
},
{
"added_on": "2013-01-01",
Expand All @@ -46,7 +47,8 @@
"tendlc_campaign_id": "ACB1234",
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10"
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
},
{
"added_on": "2013-03-25",
Expand All @@ -66,7 +68,8 @@
"tendlc_campaign_id": null,
"tendlc_registration_status": null,
"toll_free_sms_verification": "verified",
"renewal_date": "2023-05-10"
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
}
]
}
3 changes: 2 additions & 1 deletion spec/resource_numbers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def to_json(number)
tendlc_campaign_id: number.tendlc_campaign_id,
tendlc_registration_status: number.tendlc_registration_status,
toll_free_sms_verification: number.toll_free_sms_verification,
renewal_date: number.renewal_date
renewal_date: number.renewal_date,
cnam_lookup: number.cnam_lookup
}.to_json
end

Expand Down

0 comments on commit 21d7bc6

Please sign in to comment.