Skip to content

Commit

Permalink
ruby fix (#230)
Browse files Browse the repository at this point in the history
* ruby fix

* fix

* fix

* addded UTCs

* added UTCs

* added UTCs

* filters applied

* filters applied

* filters applied

* bump version

* corrected url

* correcte the example file

---------

Co-authored-by: kalyan-plivo <[email protected]>
  • Loading branch information
abheet-plivo and kalyan-plivo authored Nov 8, 2023
1 parent 9ae47c5 commit ac9a26d
Show file tree
Hide file tree
Showing 16 changed files with 407 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [4.52.0](https://github.com/plivo/plivo-ruby/tree/v4.52.0) (2023-11-08)
**[BETA] Feature - TollFree Verification API Support**
- API support for Create, Update, Get, Delete, and List Tollfree Verification.
- Added New Param `toll_free_sms_verification_id` and `toll_free_sms_verification_order_status` in to the response of the [list all numbers API], [list single number API]
- Added `toll_free_sms_verification_order_status` filter to AccountPhoneNumber - list all my numbers API.

## [4.51.0](https://github.com/plivo/plivo-ruby/tree/v4.51.0) (2023-10-16)
**Introducing campaign_source & import partner camapign API**
- New field campaign_source introduced
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.51.0'
gem 'plivo', '>= 4.52.0'
```

And then execute:
Expand Down
42 changes: 42 additions & 0 deletions examples/tollfree_verification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'rubygems'
require "plivo"

include Plivo
include Plivo::Exceptions

AUTH_ID = 'AUTH_ID'
AUTH_TOKEN = 'AUTH_TOKEN'

api = RestClient.new(AUTH_ID, AUTH_TOKEN)

begin
response = api.tollfree_verifications.get('uuid')
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end


begin
response = api.tollfree_verifications.create('18773582986', '2FA', 'dasas',
'd5a9c4d4-d086-42db-940f-e798d480d064', 'VERBAL', 'https://www.aa.com,http://google.com',
'100', 'qwqwq')
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end

begin
response = api.tollfree_verifications.update('uuid', usecase: '2FA')
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end


begin
response = api.tollfree_verifications.delete('uuid')
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end
1 change: 1 addition & 0 deletions lib/plivo/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require_relative 'resources/lookup'
require_relative 'resources/regulatory_compliance'
require_relative 'resources/multipartycalls'
require_relative 'resources/tollfree_verification'

module Plivo
module Resources
Expand Down
12 changes: 9 additions & 3 deletions lib/plivo/resources/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def to_s
voice_rate: @voice_rate,
tendlc_campaign_id: @tendlc_campaign_id,
tendlc_registration_status: @tendlc_registration_status,
toll_free_sms_verification: @toll_free_sms_verification
toll_free_sms_verification: @toll_free_sms_verification,
toll_free_sms_verification_id: @toll_free_sms_verification_id,
toll_free_sms_verification_order_status: @toll_free_sms_verification_order_status
}.to_s
end
end
Expand Down Expand Up @@ -185,7 +187,9 @@ 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,
toll_free_sms_verification_id: @toll_free_sms_verification_id,
toll_free_sms_verification_order_status: @toll_free_sms_verification_order_status
}.to_s
end
end
Expand Down Expand Up @@ -231,14 +235,16 @@ 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] :toll_free_sms_verification_id The id of tollfree verification that the number is currently linked with.
# @option options [String] :toll_free_sms_verification_order_status Indicates the tollfree verification status of a 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 toll_free_sms_verification_order_status].each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], true)
params[param] = options[param]
Expand Down
178 changes: 178 additions & 0 deletions lib/plivo/resources/tollfree_verification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
module Plivo
module Resources
include Plivo::Utils

class TollfreeVerification < Base::Resource
def initialize(client, options = nil)
@_name = 'TollfreeVerification'
@_identifier_string = 'tollfree_verification'
super
end

def update(options = nil)
return perform_update({}) if options.nil?

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

params = {}
params_expected = %i[ usecase usecase_summary profile_uuid optin_type optin_image_url volume message_sample callback_method callback_url extra_data additional_information ]
params_expected.each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], false)
params[param] = options[param]
end
end

perform_update(params)
end

def delete
perform_delete
end

def to_s
{
api_id: @api_id,
uuid: @uuid,
number: @number,
created_at: @created_at,
updated_at: @updated_at,
callback_method: @callback_url,
callback_url: @callback_url,
extra_data: @extra_data,
additional_information: @additional_information,
message_sample: @message_sample,
optin_image_url: @optin_image_url,
optin_type: @optin_type,
profile_uuid: @profile_uuid,
rejection_reason: @rejection_reason,
status: @status,
usecase: @usecase,
usecase_summary: @usecase_summary,
volume: @volume
}.delete_if { |key, value| value.nil? }.to_s
end
end

class TollfreeVerificationsInterface < Base::ResourceInterface
def initialize(client, resource_list_json = nil)
@_name = 'TollfreeVerification'
@_resource_type = TollfreeVerification
@_identifier_string = 'tollfree_verification'
super
end

##
# Get an TollfreeVerification
# @param [String] uuid
# return [TollfreeVerification]
def get(uuid)
valid_param?(:uuid, uuid, [String, Symbol], true)
perform_get(uuid)
end

##
# List all TollfreeVerification
# @param [Hash] options
# @option options [Int] :offset
# @option options [Int] :limit
# @return [Hash]
def list(options = nil)
return perform_list if options.nil?
valid_param?(:options, options, Hash, true)

params = {}
params_expected = %i[ profile_uuid number status created__lt created__gt usecase created__lte created__gte ]
params_expected.each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], true)
params[param] = options[param]
end
end

%i[offset limit].each do |param|
if options.key?(param) && valid_param?(param, options[param],
[Integer], true)
params[param] = options[param]
end
end

raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0

if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
raise_invalid_request('The maximum number of results that can be '\
"fetched is 20. limit can't be more than 20 or less than 1")
end

perform_list(params)
end

##
# Create an TollfreeVerification
# @param [String] number
# @param [String] usecase
# @param [String] usecase_summary
# @param [String] profile_uuid
# @param [String] optin_type
# @param [String] optin_image_url
# @param [String] volume
# @param [String] message_sample
# @param [String] callback_url
# @param [String] callback_method
# @param [String] extra_data
# @param [String] additional_information
# return [TollfreeVerification] TollfreeVerification
def create(number, usecase, usecase_summary, profile_uuid, optin_type, optin_image_url, volume, message_sample, callback_url = nil, callback_method = nil, extra_data = nil, additional_information = nil)
valid_param?(:number, number, [String, Symbol], true)
valid_param?(:usecase, usecase, [String, Symbol], true)
valid_param?(:usecase_summary, usecase_summary, [String, Symbol], true)
valid_param?(:profile_uuid, profile_uuid, [String, Symbol], true)
valid_param?(:optin_type, optin_type, [String, Symbol], true)
valid_param?(:optin_image_url, optin_image_url, [String, Symbol], true)
valid_param?(:volume, volume, [String, Symbol], true)
valid_param?(:message_sample, message_sample, [String, Symbol], true)
valid_param?(:callback_url, callback_url, [String, Symbol], false)
valid_param?(:callback_method, callback_method, [String, Symbol], false)
valid_param?(:extra_data, extra_data, [String, Symbol], false)
valid_param?(:additional_information, additional_information, [String, Symbol], false)

params = {
number: number,
usecase: usecase,
usecase_summary: usecase_summary,
profile_uuid: profile_uuid,
optin_type: optin_type,
optin_image_url: optin_image_url,
volume: volume,
message_sample: message_sample,
callback_url: callback_url,
callback_method: callback_method,
extra_data: extra_data,
additional_information: additional_information
}.delete_if { |key, value| value.nil? }

return perform_create(params)
end

##
# Update an TollfreeVerification
# @param [String] uuid
# @param [Hash] options
# return [TollfreeVerification]
def update(uuid, options = nil)
valid_param?(:uuid, uuid, [String, Symbol], true)
TollfreeVerification.new(@_client,
resource_id: uuid).update(options)
end

##
# Delete an TollfreeVerification.
# @param [String] uuid
def delete(uuid)
valid_param?(:uuid, uuid, [String, Symbol], true)
TollfreeVerification.new(@_client,
resource_id: uuid).delete
end
end
end
end
2 changes: 2 additions & 0 deletions lib/plivo/rest_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class RestClient < BaseClient
attr_reader :brand, :campaign, :profile
attr_reader :end_users
attr_reader :compliance_document_types, :compliance_documents, :compliance_requirements, :compliance_applications
attr_reader :tollfree_verifications

def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout = 5)
configure_base_uri
Expand Down Expand Up @@ -64,6 +65,7 @@ def configure_interfaces
@compliance_documents = Resources::ComplianceDocumentsInterface.new(self)
@compliance_requirements = Resources::ComplianceRequirementsInterface.new(self)
@compliance_applications = Resources::ComplianceApplicationsInterface.new(self)
@tollfree_verifications = Resources::TollfreeVerificationsInterface.new(self)
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.51.0".freeze
VERSION = "4.52.0".freeze
end
4 changes: 3 additions & 1 deletion spec/mocks/numberGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"toll_free_sms_verification_id": null,
"toll_free_sms_verification_order_status": null
}
12 changes: 9 additions & 3 deletions spec/mocks/numberListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"toll_free_sms_verification_id": null,
"toll_free_sms_verification_order_status": null
},
{
"added_on": "2013-01-01",
Expand All @@ -48,7 +50,9 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": null,
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"toll_free_sms_verification_id": null,
"toll_free_sms_verification_order_status": null
},
{
"added_on": "2013-03-25",
Expand All @@ -69,7 +73,9 @@
"tendlc_registration_status": null,
"toll_free_sms_verification": "verified",
"renewal_date": "2023-05-10",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"toll_free_sms_verification_id": null,
"toll_free_sms_verification_order_status": null
}
]
}
5 changes: 5 additions & 0 deletions spec/mocks/tollfreeVerificationCreateResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"api_id": "8540e282-7335-11ee-a39b-0242ac110004",
"message": "created",
"uuid": "7f4deae2-5d79-46ec-5088-218504abf664"
}
Loading

0 comments on commit ac9a26d

Please sign in to comment.