Skip to content

Commit

Permalink
Merge branch 'master' into FixMessageInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
huzaif-plivo committed Apr 25, 2021
2 parents df61fc9 + 3a25188 commit dff7303
Show file tree
Hide file tree
Showing 70 changed files with 3,642 additions and 97 deletions.
73 changes: 73 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,78 @@
# Change Log

## [4.16.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.16.0) (2021-02-08)
- Add support for Regulatory Compliance APIs.

## [4.15.2](https://github.com/plivo/plivo-ruby/releases/tag/v4.15.2) (2021-01-27)
- Fix Call API resource - Set answer_method as Optional param.

## [4.15.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.15.1) (2021-01-06)
- Fix Search Phone Numbers API using City Attribute.

## [4.15.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.15.0) (2020-11-17)
- Add number_priority support for Powerpack API.

## [4.14.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.14.0) (2020-10-30)
- Change lookup API endpoint and response.

## [4.13.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.13.0) (2020-09-30)
- Add support for Lookup API

## [4.12.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.12.0) (2020-09-24)
- Add "public_uri" optional param support for Application API.

## [4.11.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.11.0) (2020-08-25)
- Add Powerpack for mms

## [4.10.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.10.0) (2020-09-04)
- Add ConferenceUuid & CallState for Get Details of a Call API
- Upgrade faraday & faraday_middleware dependencies

## [4.9.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.1) (2020-08-19)
- Internal changes in Phlo for MultiPartyCall component

## [4.9.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.9.0) (2020-07-23)
- Add retries to multiple regions for voice requests.

## [4.8.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.8.1) (2020-06-05)
- Fix Record a Conference API response.

## [4.8.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.8.0) (2020-05-28)
- Add JWT helper functions.

## [4.7.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.7.1) (2020-05-06)
- Fix Send MMS with existing media_ids.

## [4.7.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.7.0) (2020-04-29)
- Add V3 signature helper functions.

## [4.6.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.6.1) (2020-04-02)
- Add nil check for API requests.

## [4.6.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.6.0) (2020-03-31)
- Add application cascade delete support.

## [4.5.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.5.0) (2020-03-30)
- Add Tollfree support for Powerpack

## [4.4.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.4.0) (2020-03-27)
- Add post call quality feedback API support.

## [4.3.5](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.5) (2019-12-28)
- Add Media support

## [4.3.4](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.4) (2019-12-20)
- Add Powerpack support

## [4.3.3](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.3) (2019-12-04)
- Add MMS support

## [4.3.2](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.2) (2019-11-13)
- Add GetInput XML support

## [4.3.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.1) (2019-10-16)
- Add SSML support

## [4.3.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.0) (2019-03-12)
- Add PHLO support
- Add Multi-Party Call triggers
Expand Down
7 changes: 7 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!groovy

@Library('plivo_standard_libs@sdks') _

sdksPipeline ([
buildContainer: 'plivo/jenkins-ci/plivo-rubysdk:master'
])
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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.3.0'
gem 'plivo', '>= 4.16.0'
```

And then execute:
Expand Down Expand Up @@ -105,6 +105,18 @@ call_made = client.calls.create(
)
```

### Lookup a number

```ruby
require 'rubygems'
require 'plivo'

include Plivo

client = RestClient.new
resp = client.lookup.get('<number-here>')
```

### Generate Plivo XML

```ruby
Expand Down
7 changes: 7 additions & 0 deletions ci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
parent: central
serviceName: plivo-ruby
language: ruby-sdk
build:
command: |
gem build plivo.gemspec
32 changes: 32 additions & 0 deletions examples/jwt.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'rubygems'
require 'plivo'

include Plivo

AUTH_ID = 'MADADADADADADADADADA'
AUTH_TOKEN = 'AUTH_TOKEN'

begin
acctkn = Plivo::Token::AccessToken.new(
AUTH_ID,
AUTH_TOKEN,
'{username}',
'{uid}'
)
# update token validity (from, lifetime)
acctkn.update_validity(Time.now, 300)
# add voice grants (incoming, outgoing)
acctkn.add_voice_grants(Plivo::Token::VoiceGrants.new(true, true))
puts acctkn.to_jwt

# update token validity (from, nil, till)
acctkn.update_validity(Time.now, nil, Time.now + 300)
# add voice grants (incoming, outgoing)
acctkn.add_voice_grants(Plivo::Token::VoiceGrants.new(true, true))
puts acctkn.to_jwt
rescue ValidationError => e
puts 'Exception: ' + e.message
end

# Sample Response:
#
24 changes: 24 additions & 0 deletions examples/lookup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require "rubygems"
require "plivo"

include Plivo
include Plivo::Exceptions

AUTH_ID = ""
AUTH_TOKEN = ""

client = RestClient.new(AUTH_ID, AUTH_TOKEN)

# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
# then initialize client as:
# client = RestClient.new

begin
resp = client.lookup.get(
"<insert-number-here>",
"carrier"
)
puts resp
rescue PlivoRESTError => e
puts "Exception: " + e.message
end
167 changes: 167 additions & 0 deletions examples/regulatory_compliance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
require "rubygems"
require "plivo"

include Plivo
include Plivo::Exceptions

AUTH_ID = ""
AUTH_TOKEN = ""

client = RestClient.new(AUTH_ID, AUTH_TOKEN)

# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
# then initialize client as:
# client = RestClient.new

# 1. EndUSers
begin
resp = client.end_users.create('Sample First Name',
'Sample last name',
'individual')
puts resp
rescue PlivoRESTError => e
puts "Exception: " + e.message
end


# Response:
# {
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
# "end_user_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
# "name": "Sample First Name",
# "last_name": 'Sample last name',
# "end_user_type": 'individual',
# "created_on": '2021-02-08T05:28:49.238152984Z',
# "message": "created"
# }

# 2. Compliance Document Type
begin
resp = client.compliance_document_types.get('6264e9ee-5826-4f9a-80ce-00b00f7a6c0c')
puts resp
rescue PlivoRESTError => e
puts "Exception: " + e.message
end

# Response:
# {
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
# "document_type_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
# "document_name": "Address Information",
# "description": 'End User Residential Address information',
# "information": [
# {
# "enums": [
# "Water",
# "Electricity",
# "Gas",
# "Property Rental",
# "Others"
# ],
# "field_name": "type_of_utility",
# "field_type": "enum",
# "friendly_name": "Type of Utility"
# }
# ],
# "proof_required": "Scanned copy of the Bill",
# "created_at": '2018-11-03 19:32:33.240504+00:00'
# }

# 3. Compliance Documents
begin
resp = client.compliance_documents.list(
limit: 5,
offset: 0,
document_type_id: '15d48097-6fd6-4bbc-97ee-0c3dd0a8fe1a',
end_user_id: '4493840308')
puts resp
rescue PlivoRESTError => e
puts "Exception: " + e.message
end

# Response
# {
# "alias": "test alias",
# "api_id": "3cfabf1a-6579-11eb-b408-0242ac110005",
# "created_at": "2021-02-02 08:08:10.312992 +0000 UTC",
# "document_id": "4a9599cc-c58c-4804-8c04-1d4918cb6df7",
# "document_type_id": "be903190-cc96-4fd8-b3cd-97832fe7c086",
# "end_user_id": "652e1445-1657-4a80-972f-6dbd467b00b5",
# "meta_information": {
# "use_case_description": "test"
# }
#}

# 4. Compliance Requirements
begin
resp = client.compliance_requirements.list(
country_iso2: 'ES',
end_user_type: 'business',
number_type: 'local')
puts resp
rescue PlivoRESTError => e
puts "Exception: " + e.message
end

# Response:
#{
# "acceptable_document_types": [
# {
# "acceptable_documents": [
# {
# "document_type_id": "e68cf5fe-cea0-4b6c-a2b1-bef1d9add467",
# "document_type_name": "Address Information"
# }
# ],
# "name": "End User Address Details",
# "scope": "local"
# },
# {
# "acceptable_documents": [
# {
# "document_type_id": "e9b0b6fb-fd2f-44c1-9428-ee69afbd808b",
# "document_type_name": "Utility Bill"
# }
# ],
# "name": "Proof of Address ",
# "scope": "local"
# }
# ],
# "api_id": "75ea8886-6499-11eb-ad59-0242ac110005",
# "compliance_requirement_id": "4ae473b0-f154-41a4-aba8-ab76be12f27f",
# "country_iso2": "ES",
# "end_user_type": "individual",
# "number_type": "local"
#}

# 5. Compliance Applications
begin
resp = client.compliance_applications.create(
alias_: 'test',
compliance_requirement_id: '4ae473b0-f154-41a4-aba8-ab76be12f27f',
end_user_type: 'individual'
end_user_id: 'f7ba78e0-1d31-4f75-842c-cd2f91334d9f',
document_ids: ["a663bc92-5c8e-4e95-80d5-ba75d3569a98","4a9599cc-c58c-4804-8c04-1d4918cb6df7"],
country_iso2: 'FR',
number_type: 'mobile'
)
puts resp
rescue PlivoRESTError => e
puts "Exception: " + e.message
end

# Response:
# {
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
# "alias": "test",
# "compliance_application_id": "7c83fd87-fb5d-4a88-bde0-7c96da35f1e6",
# "compliance_requirement_id": "4ae473b0-f154-41a4-aba8-ab76be12f27f",
# "country_iso2": "FR",
# "documents": [],
# "end_user_id": "f7ba78e0-1d31-4f75-842c-cd2f91334d9f",
# "end_user_type": "individual",
# "message": "created",
# "number_type": "local",
# "status": "draft",
# "created_at": '2021-02-08T19:32:33.240504+00:00'
# }
1 change: 1 addition & 0 deletions lib/plivo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require_relative 'plivo/resources'
require_relative 'plivo/rest_client'
require_relative 'plivo/xml'
require_relative 'plivo/jwt'
require_relative 'plivo/phlo_client'
require_relative 'plivo/base_client'

Expand Down
7 changes: 7 additions & 0 deletions lib/plivo/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
module Plivo
module Base
PLIVO_API_URL = 'https://api.plivo.com'.freeze

API_VOICE = 'https://voice.plivo.com'.freeze
API_VOICE_FALLBACK_1 = 'https://voice-usw1.plivo.com'.freeze
API_VOICE_FALLBACK_2 = 'https://voice-use1.plivo.com'.freeze

CALLINSIGHTS_API_URL = 'https://stats.plivo.com'.freeze
PHLO_API_URL = 'https://phlorunner.plivo.com'.freeze
LOOKUP_API_URL = 'https://lookup.plivo.com'.freeze
end
end
Loading

0 comments on commit dff7303

Please sign in to comment.