Skip to content

Commit

Permalink
Merge branch 'master' into SMS-6439
Browse files Browse the repository at this point in the history
  • Loading branch information
rajneeshkatkam-plivo committed Nov 9, 2023
2 parents 166bb25 + 5477cc2 commit 75b2109
Show file tree
Hide file tree
Showing 22 changed files with 745 additions and 13 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# Change Log

## [4.52.0](https://github.com/plivo/plivo-ruby/tree/v4.52.0) (2023-11-10)
## [4.54.0](https://github.com/plivo/plivo-ruby/tree/v4.54.0) (2023-11-10)
**Feature - Added New Param 'registration_status' for Campaign List**
- Added new query param "registration_status" for campaign list

## [4.53.0](https://github.com/plivo/plivo-ruby/tree/v4.53.0) (2023-11-08)
**Feature - Verify Service**
-Added Support for Verify Service Public API'S
-Create Session API(POST): To create a verify session (2FA). Allowed params recipient, method, channel, callback_url, app_uuid
-Get Session API(GET): To retrieve a particular session
-List Sessions : To retrieve all the sessions
-Validate Session : To validate OTP for a particular session

## [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 All @@ -21,6 +35,7 @@
**Feature - Added New Param 'carrier_fees', 'carrier_fees_rate', 'destination_network' in Get Message and List Message APIs**
- Added new params on message get and list response


## [4.47.0](https://github.com/plivo/plivo-ruby/tree/v4.47.0) (2023-08-03)
**Feature - DLT parameters**
- Added new params `DLTEntityID`, `DLTTemplateID`, `DLTTemplateCategory` to the [send message API](https://www.plivo.com/docs/sms/api/message/send-a-message/)
Expand Down
4 changes: 2 additions & 2 deletions 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.52.0'
gem 'plivo', '>= 4.54.0'
```

And then execute:
Expand Down Expand Up @@ -197,4 +197,4 @@ export PLIVO_API_PROD_HOST=<plivoapi_public_endpoint>
(The docker container should be running)

> Test code and unit tests can also be run within the container using
`make run` and `make test` respectively. (`CONTAINER` argument should be omitted when running from the container)
`make run` and `make test` respectively. (`CONTAINER` argument should be omitted when running from the container)
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
2 changes: 1 addition & 1 deletion lib/plivo/base/resource_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def perform_list(params = nil)
objects: @_resource_list
}
end

def perform_action(action = nil, method = 'GET', params = nil, parse = false)
resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
response = @_client.send_request(resource_path, method, params, nil, false, is_voice_request: @_is_voice_request)
Expand Down
2 changes: 2 additions & 0 deletions lib/plivo/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
require_relative 'resources/lookup'
require_relative 'resources/regulatory_compliance'
require_relative 'resources/multipartycalls'
require_relative 'resources/verify_session'
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
Loading

0 comments on commit 75b2109

Please sign in to comment.