cpaas-sdk 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8be04a70b357316c000cfc6437488b4d71d34bcf528bef33136c7dcc36cc0858
4
- data.tar.gz: f3fd34a38d1828259e6017edb66d4976c30983da9cc37b4fc59e814de77efeef
3
+ metadata.gz: 3bd743f490632a5245f1c0cd2baf7187cf8623f38ded092fe0f020470445e419
4
+ data.tar.gz: 4b9bfcd28a1bf3c555686f79eea6e6c10fd276a2192f4dbf28cffc3ee9d87fd4
5
5
  SHA512:
6
- metadata.gz: d9f9d3c7ac7369828012a8bfa7a40ab5a0288674c124d229b67ce39f4e2ee9e9f87ba6611d720730e31c3cf9157e384fe346d513780d6d3b4a93570f021dcec8
7
- data.tar.gz: a0a41e797bda278bba07beef141cbfe7afd64950ba1e23836e9a86b4152488b5709d9df22fcda1c0ba9584e1899599531efd49d87108ffc4d6d0a35f184c397b
6
+ metadata.gz: 202495f68be89189d7336ce9d1a282aa35832a7699d621935d366e08d4ce720d72afcd002ee59bf0f7c5fba4e8f0e70a655fba247781c4f9b4a06b365f1e9a19
7
+ data.tar.gz: 9f69c5ce0195a0dc4e88eeb2e41770d897a390bf3328218f28ae676216b4ddfa4601afbbbc223b3111ed5e145961b8ffcea78c8b44afd81e4d85d4baa729b625
data/.gitignore CHANGED
@@ -9,3 +9,5 @@ Gemfile.lock
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ /cpaas-*.gem
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  + This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
  + The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) recommendations.
7
7
 
8
+ ## 1.1.0 - 2019-12-10
9
+
10
+ ### Added
11
+ - Added `subject` to list of params for Twofactor's sendCode and resendCode methods to enable sending code via email.
8
12
 
9
13
  ## 1.0.0
10
14
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in cpaas-ruby.gemspec
3
+ # Specify your gem's dependencies in cpaas-sdk.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add this line to your application's Gemfile:
6
6
 
7
7
  ```ruby
8
- gem 'cpaas-ruby'
8
+ gem 'cpaas-sdk'
9
9
  ```
10
10
 
11
11
  And then execute:
@@ -14,7 +14,7 @@ And then execute:
14
14
 
15
15
  Or install it yourself as:
16
16
 
17
- $ gem install cpaas-ruby
17
+ $ gem install cpaas-sdk
18
18
 
19
19
  ## Reference
20
20
 
File without changes
data/examples/2fa/Gemfile CHANGED
@@ -5,4 +5,4 @@ gem 'httparty'
5
5
  gem 'dotenv'
6
6
  gem 'rerun'
7
7
  gem 'pry'
8
- gem 'cpaas-sdk', path: './../../'
8
+ gem 'cpaas-sdk', '~> 1.0'
data/examples/sms/Gemfile CHANGED
@@ -5,4 +5,4 @@ gem 'httparty'
5
5
  gem 'dotenv'
6
6
  gem 'rerun'
7
7
  gem 'pry'
8
- gem 'cpaas-sdk', path: './../../'
8
+ gem 'cpaas-sdk', '~> 1.0'
data/examples/sms/app.rb CHANGED
@@ -30,7 +30,6 @@ class App < Sinatra::Application
30
30
  #
31
31
  # The method create_message would send an sms when the 'type' attribute is 'SMS'
32
32
  #
33
- puts ENV['PHONE_NUMBER']
34
33
  response = Cpaas::Conversation.create_message({
35
34
  type: Cpaas::Conversation.types[:SMS],
36
35
  destination_address: params['number'],
@@ -3,6 +3,9 @@ require 'rubygems'
3
3
  require 'bundler'
4
4
 
5
5
  require './app'
6
+ require './helper'
7
+
8
+ initial_setup
6
9
 
7
10
  Bundler.require
8
11
  Dotenv.load
@@ -1,5 +1,6 @@
1
1
  FILE_NAME = 'notifications.json'
2
- PATH = "#{Dir.pwd}/tmp/#{FILE_NAME}"
2
+ DIR_NAME = "tmp"
3
+ PATH = "#{Dir.pwd}/#{DIR_NAME}/#{FILE_NAME}"
3
4
 
4
5
  def error_message(error)
5
6
  "#{error[:name]}: #{error[:message]} (#{error[:exception_id]})"
@@ -31,3 +32,16 @@ def write_file(content)
31
32
  notification_file.puts(content)
32
33
  notification_file.close
33
34
  end
35
+
36
+ def initial_setup
37
+ if !File.file?(PATH)
38
+ dirname = File.dirname(Dir.pwd)
39
+ unless File.directory?(DIR_NAME)
40
+ FileUtils.mkdir_p(DIR_NAME)
41
+ end
42
+
43
+ notification_file = File.new(PATH, 'w')
44
+ notification_file.puts("{}")
45
+ notification_file.close
46
+ end
47
+ end
@@ -14,6 +14,7 @@ module Cpaas
14
14
  # @option params [String|Array[string]] :destination_address Destination address of the authentication code being sent. For sms type authentication codes, it should contain a E164 phone number. For e-mail type authentication codes, it should contain a valid e-mail address.
15
15
  # @option params [String] :message Message text sent to the destination, containing the placeholder for the code within the text. CPaaS requires to have *{code}* string within the text in order to generate a code and inject into the text. For email type code, one usage is to have the *{code}* string located within the link in order to get a unique link.
16
16
  # @option params [String] :method ('sms') +optional+ Type of the authentication code delivery method, sms and email are supported types. Possible values: sms, email
17
+ # @option params [String] :subject +optional+ When the method is passed as email then subject becomes a mandatory field to pass. The value passed becomes the subject line of the 2FA code email that is sent out to the destination_address.
17
18
  # @option params [Number] :expiry (120) +optional+ Lifetime duration of the code sent in seconds. This can contain values between 30 and 3600 seconds.
18
19
  # @option params [Number] :length (6) +optional+ Length of the authentication code tha CPaaS should generate for this request. It can contain values between 4 and 10.
19
20
  # @option params [String] :type ('numeric') +optional+ Type of the code that is generated. If not provided, default value is numeric. Possible values: numeric, alphanumeric, alphabetic
@@ -31,6 +32,7 @@ module Cpaas
31
32
  type: params[:type] || 'numeric'
32
33
  },
33
34
  expiry: params[:expiry] || 120,
35
+ subject: params[:subject],
34
36
  message: params[:message]
35
37
  }
36
38
  }
@@ -86,6 +88,7 @@ module Cpaas
86
88
  # @option params [String] :message Message text sent to the destination, containing the placeholder for the code within the text. CPaaS requires to have *{code}* string within the text in order to generate a code and inject into the text. For email type code, one usage is to have the *{code}* string located within the link in order to get a unique link.
87
89
  # @option params [String] :code_id ID of the authentication code.
88
90
  # @option params [String] :method ('sms') +optional+ Type of the authentication code delivery method, sms and email are supported types. Possible values: sms, email
91
+ # @option params [String] :subject +optional+ When the method is passed as email then subject becomes a mandatory field to pass. The value passed becomes the subject line of the 2FA code email that is sent out to the destination_address.
89
92
  # @option params [Number] :expiry (120) +optional+ Lifetime duration of the code sent in seconds. This can contain values between 30 and 3600 seconds.
90
93
  # @option params [Number] :length (6) +optional+ Length of the authentication code tha CPaaS should generate for this request. It can contain values between 4 and 10.
91
94
  # @option params [String] :type ('numeric') +optional+ Type of the code that is generated. If not provided, default value is numeric. Possible values: numeric, alphanumeric, alphabetic
@@ -103,6 +106,7 @@ module Cpaas
103
106
  type: params[:type] || 'numeric'
104
107
  },
105
108
  expiry: params[:expiry] || 120,
109
+ subject: params[:subject],
106
110
  message: params[:message]
107
111
  }
108
112
  }
@@ -1,3 +1,3 @@
1
1
  module Cpaas
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
data/tutorials/2FA.md CHANGED
@@ -39,7 +39,7 @@ The response contains `code_id` which is a unique ID needed for `verify_code`. T
39
39
 
40
40
  Walking through the method parameters:
41
41
 
42
- + `destination_address` is required with a routable destination number in E.164 format, either with tel schema or not. For v1, only one address is supported.
42
+ + `destination_address` is required with a routable destination number in E.164 format, either with tel schema or not. For SDK v1, only one address is supported.
43
43
  + `method` is mandatory and must have `sms` for verification via SMS flow.
44
44
  + `expiry` indicates the desired period of time in seconds that the code will be valid on $KANDY$. It is optional having default value as 120 seconds, while application can ask for values between 30 and 3600 seconds.
45
45
  + `message` is required with a `{code}` string within the text so that $KANDY$ can replace that with the real code generated, and send it as the SMS content.
@@ -76,7 +76,7 @@ An invalid/failed verification will have the following response:
76
76
  ## Two-Factor Authentication via E-mail
77
77
  A similar flow with the SMS section above can be implemented for e-mail verification.
78
78
 
79
- The following email code request example, requires insertion of the generated code within the link that the user is supposed to click and navigate to the application's web service:
79
+ The following email code request example, requires an additional parameter `subject`. When value `email` is used in the `method` parameter then `subject` becomes a mandatory field to pass. The value passed becomes the subject line of the 2FA code email that is sent out to the destinationAddress:
80
80
 
81
81
  ```ruby
82
82
  Cpaas::Twofactor.send_code({
@@ -85,7 +85,8 @@ Cpaas::Twofactor.send_code({
85
85
  length: 10,
86
86
  type: 'alphanumeric',
87
87
  expiry: 3600,
88
- message: 'Here is your code: {code}'
88
+ message: 'Here is your code: {code}',
89
+ subject: 'Verification code'
89
90
  })
90
91
  ```
91
92
  The response contains `code_id` which is a unique ID needed for `verify_code`. The response object can look something like this:
@@ -95,7 +96,7 @@ The response contains `code_id` which is a unique ID needed for `verify_code`. T
95
96
  }
96
97
  ```
97
98
 
98
- As can be seen within the example, `method` parameter has `email` value, while `destination_address` field includes a destination e-mail address. For v1, only plain text is supported.
99
+ As can be seen within the example, `method` parameter has `email` value, while `destination_address` field includes a destination e-mail address. For SDK v1, only plain text is supported.
99
100
 
100
101
  Verification procedure for two-factor authentication via e-mail is same with two-factor authentication via SMS as described in previous section.
101
102
 
@@ -9,7 +9,7 @@ To begin, you will need to install the ruby library in your application. The lib
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'cpaas-ruby'
12
+ gem 'cpaas-sdk'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -20,7 +20,7 @@ bundle
20
20
 
21
21
  Or install it yourself as:
22
22
  ```bash
23
- gem install cpaas-ruby
23
+ gem install cpaas-sdk
24
24
  ```
25
25
 
26
26
  In your application, you simply need to create a new initializer `config/initializers/cpaas.rb`.
@@ -36,6 +36,15 @@ After you've configured the SDK client, you can begin playing around with it to
36
36
 
37
37
  ## Configuration
38
38
 
39
+ Before starting, you need to learn following information from your CPaaS account, specifically from Developer Portal.
40
+
41
+ Log into your Developer Portal account and the configuration information required to be authenticated should be under:
42
+
43
+ + `Projects` -> `{your project}` -> `Project info`/`Project secret`
44
+
45
+ > + `Private Project key` should be mapped to `client_id`
46
+ > + `Private Project secret` should be mapped to `client_secret`
47
+
39
48
  ```ruby
40
49
  Cpaas.configure do |config|
41
50
  config.client_id = '<private project key>'
@@ -44,16 +53,9 @@ Cpaas.configure do |config|
44
53
  end
45
54
  ```
46
55
 
47
- The information required to be authenticated should be under:
48
-
49
- + `Projects` -> `{your project}` -> `Project info`/`Project secret`
50
-
51
- > + `Private Project key` should be mapped to `client_id`
52
- > + `Private Project secret` should be mapped to `client_secret`
53
-
54
56
  ## Usage
55
57
 
56
- All modules can be accessed via the client instance. All method invocations follow the namespaced signature
58
+ All modules can be accessed via `Cpaas`, refer to [References](/developer/references/ruby) for details about all modules and it's methods. All method invocations follow the namespaced signature
57
59
 
58
60
  `{Client}::{ModuleName}.{method_name}(params)`
59
61
 
@@ -16,16 +16,15 @@ Before moving to how the response body looks, let's walk through the highlights
16
16
 
17
17
  + `sender_address` indicates which DID number that user desires to send the SMS from. It is expected to be an E.164 formatted number.
18
18
  + If `sender_address` field contains `default` keyword, $KANDY$ discovers the default assigned SMS DID number for that user and utilizes it as the sender address.
19
- + `destination_address` can either be an array of phone numbers or a single phone number string within the params containing the destinations that corresponding SMS message will be sent. For v1, only one destination is supported on $KANDY$.
19
+ + `destination_address` can either be an array of phone numbers or a single phone number string within the params containing the destinations that corresponding SMS message will be sent. For SDK v1, only one destination is supported on $KANDY$.
20
20
  + Address value needs to contain a phone number, ideally in E.164 format. Some valid formats are:
21
21
  - +16131234567
22
- - 6131234567
23
22
  - tel:+16131234567
24
23
  - sip:+16131234567@domain
25
24
  - sip:6131234567@domain
26
25
  + `message` field contains the text message in `UTF-8` encoded format.
27
26
 
28
- > The number provided in `sender_address` field should be an assigned/purchased number for the user, otherwise $KANDY$ replies back with a Forbidden error.
27
+ > The number provided in `sender_address` field should be purchased by the account and assigned to the project, otherwise $KANDY$ replies back with a Forbidden error.
29
28
 
30
29
  Now, let's check the successful response:
31
30
 
@@ -39,9 +38,9 @@ Now, let's check the successful response:
39
38
  sender_address: '+16139998877'
40
39
  }
41
40
  ```
42
- In case of requesting `default` sender_address usage, sender_address field in response can be used to understand the actual number used since it contains the number being used as from address.
41
+ In case of passing `default` as sender_address in the request, the actual number from which sms is sent can be identified with `sender_address` field in the response
43
42
 
44
- > + The delivery_status can have the following values `DeliveredToNetwork`, `DeliveryImpossible`
43
+ > + The delivery_status can have the following values: `DeliveredToNetwork`, `DeliveryImpossible`
45
44
 
46
45
 
47
46
  ## Receive SMS
@@ -60,7 +59,7 @@ Cpaas::Conversation.subscribe({
60
59
  destination_address: '+16139998877'
61
60
  })
62
61
  ```
63
- + `destination_address` is an optional parameter to indicate which SMS DID number has been desired to receive SMS messages. Corresponding number should be one of the assigned/purchased numbers of the user or project/application, otherwise $KANDY$ replies back with Forbidden error. Also not providing this parameter triggers $KANDY$ to use the default assigned DID number against this user, in which case the response message for the subscription contains the `destination_address` field. It is highly recommended to provide `destination_address` parameter.
62
+ + `destination_address` is an optional parameter to indicate which SMS DID number has been desired to receive SMS messages. Corresponding number should be one of the assigned/purchased numbers of the project, otherwise $KANDY$ replies back with Forbidden error. Also not providing this parameter triggers $KANDY$ to use the default assigned DID number against this user, in which case the response message for the subscription contains the `destination_address` field. It is highly recommended to provide `destination_address` parameter.
64
63
  + `webhook_url` is a webhook that is present in your application which is accessible from the public web. The sms notifications would be delivered to the webhook and the received notification can be consumed by using the `Cpaas::Notification.parse` helper method. The usage of `Cpaas::Notification.parse` is explained in Step 2.
65
64
 
66
65
  A successful subscription would return:
@@ -73,7 +72,7 @@ A successful subscription would return:
73
72
  ```
74
73
 
75
74
  > + For every number required to receive incoming SMS, there should be an individual subscription.
76
- > + When a number has been unassigned from a user or project/application, all corresponding inbound SMS subscriptions are cancelled and `sms_subscription_cancellation_notification` notification is sent.
75
+ > + When a number has been unassigned from a project, all corresponding inbound SMS subscriptions are cancelled and `sms_subscription_cancellation_notification` notification is sent.
77
76
 
78
77
  Now, you are ready to receive inbound SMS messages via webhook, for example - 'https://myapp.com/inbound-sms/webhook'.
79
78
 
data/tutorials/index.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
- <title>Node.js SDK Tutorials</title>
6
+ <title>Ruby SDK Tutorials</title>
7
7
  <link rel="stylesheet" href="https://unpkg.com/docute@4/dist/docute.css">
8
8
  </head>
9
9
  <body>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpaas-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keepworks
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-17 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,7 +143,7 @@ files:
143
143
  - docs/Cpaas.html
144
144
  - docs/Cpaas/Conversation.html
145
145
  - docs/Cpaas/Notification.html
146
- - docs/Cpaas/TwoFactor.html
146
+ - docs/Cpaas/Twofactor.html
147
147
  - docs/_index.html
148
148
  - docs/_index.md
149
149
  - docs/class_list.html