messagebird-rest 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fef609127e904a092153ab2dc6e80cd6a775b7d0
4
- data.tar.gz: c75c619d065f6e551e9d875098d089915da4bcd2
3
+ metadata.gz: 4726ce8ee0e2583a41d1f73a7e6866dda139fb14
4
+ data.tar.gz: 484cd5e20ed84a89ea58e969289e58daa2d02bdd
5
5
  SHA512:
6
- metadata.gz: d5ed9a42b17dfbdfe55a6b8c2a88218b48001edb8764e748b42e5777406f5fe5d8ce9bd60ebf7801461f8211eecd46e481645c9c068ab59c1dd1ead037a5b07c
7
- data.tar.gz: 8dcca59dca9154927d34ebb5dfcb4b1104427c8dc50fc9b1de7f969583a5a6d536ca3042bc41df4c7c22fd51216f0ab4fc26212b79c6196aa2e8c47344878035
6
+ metadata.gz: 79a490c8dd3d3af74ff5ab0bb45209982f35dae182fc6b83cb90177e5b75a60afd36c56bb4285f0affbc1fff15cc7eacf0542e88a1fe742fc88c5a39eee11985
7
+ data.tar.gz: 6869c83755659c52549eee08b411076a42ed4c469d7ba1b8016f1b3b1668e681db46d8439ac32c2fcb32054207db9a51cdbf76d57c76ddf3d352af121c6ef26b
data/README.md CHANGED
@@ -4,7 +4,7 @@ This repository contains the open source Ruby client for MessageBird's REST API.
4
4
 
5
5
  Requirements
6
6
  ------------
7
- - [Sign up](https://www.messagebird.com/en/signup) for a free MessageBird account
7
+ - [Sign up](https://dashboard.messagebird.com/app/en/sign-up) for a free MessageBird account
8
8
  - Create a new `access_key` in the developers sections
9
9
  - MessageBird's API client for Ruby requires Ruby >= 1.9
10
10
 
@@ -111,14 +111,14 @@ Similar to the **message_create** and **message** methods, the **hlr_create** me
111
111
  client.hlr('4933bed0453ba7455031712h16830892')
112
112
  ```
113
113
 
114
- ##### OTP (One-Time Password)
115
- You can send and verify One-Time Passwords through the MessageBird API using the **otp_generate** and **otp_verify** methods.
114
+ ##### Verify (One-Time Password)
115
+ You can send and verify One-Time Passwords through the MessageBird API using the **verify_create** and **verify_token** methods.
116
116
 
117
117
  ```ruby
118
- # otp_generate requires a recipient as a required parameter, and other optional paramaters
119
- client.otp_generate(31612345678, {:reference => "YourReference"})
118
+ # verify_create requires a recipient as a required parameter, and other optional paramaters
119
+ client.verify_create(31612345678, {:reference => "YourReference"})
120
120
 
121
- #<MessageBird::OTP:0x007fb3c18c8148
121
+ #<MessageBird::Verify:0x007fb3c18c8148
122
122
  @id="080b7f804555213678f14f6o24607735",
123
123
  @recipient="31612345678",
124
124
  @reference="YourReference",
@@ -128,11 +128,11 @@ client.otp_generate(31612345678, {:reference => "YourReference"})
128
128
  @validUntilDatetime=2015-05-12 16:51:49 +0200>
129
129
  ```
130
130
 
131
- This sends a token to the recipient, which can be verified with the **otp_verify** method.
131
+ This sends a token to the recipient, which can be verified with the **verify_token** method.
132
132
 
133
133
  ```ruby
134
- # otp_verify requires a recipient, a token as required parameters, and other optional paramaters
135
- client.otp_verify(31612345678, 123456, {:reference => "YourReference"})
134
+ # verify_token requires the id of the verify request and a token as required parameters.
135
+ client.verify_token('080b7f804555213678f14f6o24607735', 123456)
136
136
  ```
137
137
 
138
138
  ##### Voice Message
data/lib/messagebird.rb CHANGED
@@ -2,7 +2,7 @@ libdir = File.dirname(__FILE__)
2
2
  $:.unshift(libdir) unless $:.include?(libdir)
3
3
 
4
4
  module MessageBird
5
- CLIENT_VERSION = '1.3.2'
5
+ CLIENT_VERSION = '1.3.3'
6
6
  ENDPOINT = 'https://rest.messagebird.com'
7
7
  end
8
8
 
@@ -10,6 +10,6 @@ require 'messagebird/balance'
10
10
  require 'messagebird/client'
11
11
  require 'messagebird/error'
12
12
  require 'messagebird/hlr'
13
- require 'messagebird/otp'
13
+ require 'messagebird/verify'
14
14
  require 'messagebird/message'
15
15
  require 'messagebird/voicemessage'
@@ -5,7 +5,7 @@ require 'uri'
5
5
  require 'messagebird/balance'
6
6
  require 'messagebird/error'
7
7
  require 'messagebird/hlr'
8
- require 'messagebird/otp'
8
+ require 'messagebird/verify'
9
9
  require 'messagebird/message'
10
10
  require 'messagebird/voicemessage'
11
11
  require 'messagebird/lookup'
@@ -19,6 +19,8 @@ module MessageBird
19
19
  end
20
20
  end
21
21
 
22
+ class InvalidPhoneNumberException < TypeError; end
23
+
22
24
  class Client
23
25
  attr_reader :access_key
24
26
 
@@ -51,7 +53,7 @@ module MessageBird
51
53
  when 200, 201, 204, 401, 404, 405, 422
52
54
  json = JSON.parse(response.body)
53
55
  else
54
- raise Net::HTTPServerError.new response.http_version, 'Unknown response from server', response
56
+ raise InvalidPhoneNumberException, 'Unknown response from server'
55
57
  end
56
58
 
57
59
  # If the request returned errors, create Error objects and raise.
@@ -81,27 +83,30 @@ module MessageBird
81
83
  :reference => reference))
82
84
  end
83
85
 
84
- # Generate a new One-Time-Password message
85
- def otp_generate(recipient, params={})
86
- OTP.new(request(
87
- :post,
88
- 'otp/generate',
89
- params.merge({
90
- :recipient => recipient
91
- })
92
- ))
86
+ # Retrieve the information of specific Verify.
87
+ def verify(id)
88
+ Verify.new(request(:get, "verify/#{id.to_s}"))
93
89
  end
94
90
 
95
- # Verify the One-Time-Password
96
- def otp_verify(recipient, token, params={})
97
- # Set the path to include all the parameters
98
- # Blame Sam Wierema for not adhering to REST principles...
99
- path = 'otp/verify?' + URI.encode_www_form(params.merge({
100
- :recipient => recipient,
101
- :token => token
102
- }))
91
+ # Generate a new One-Time-Password message.
92
+ def verify_create(recipient, params={})
93
+ Verify.new(request(
94
+ :post,
95
+ 'verify',
96
+ params.merge({
97
+ :recipient => recipient
98
+ })
99
+ ))
100
+ end
103
101
 
104
- OTP.new(request(:get, path))
102
+ # Verify the One-Time-Password.
103
+ def verify_token(id, token)
104
+ Verify.new(request(:get, "verify/#{id.to_s}?token=#{token}"))
105
+ end
106
+
107
+ # Delete a Verify
108
+ def verify_delete(id)
109
+ Verify.new(request(:delete, "verify/#{id.to_s}"))
105
110
  end
106
111
 
107
112
  # Retrieve the information of specific message.
@@ -141,7 +146,7 @@ module MessageBird
141
146
 
142
147
  def lookup(phoneNumber, params={})
143
148
  Lookup.new(request(:get, "lookup/#{phoneNumber}", params))
144
- end
149
+ end
145
150
 
146
151
  def lookup_hlr_create(phoneNumber, params={})
147
152
  HLR.new(request(:post, "lookup/#{phoneNumber}/hlr", params))
@@ -3,7 +3,7 @@ require 'time'
3
3
  require 'messagebird/base'
4
4
 
5
5
  module MessageBird
6
- class OTP < MessageBird::Base
6
+ class Verify < MessageBird::Base
7
7
  attr_accessor :id, :recipient, :reference, :status, :href,
8
8
  :createdDatetime, :validUntilDatetime
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: messagebird-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maurice Nonnekes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2018-05-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple REST API for MessageBird in Ruby
14
14
  email: maurice@messagebird.com
@@ -16,6 +16,9 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/messagebird.rb
19
22
  - lib/messagebird/balance.rb
20
23
  - lib/messagebird/base.rb
21
24
  - lib/messagebird/client.rb
@@ -23,12 +26,9 @@ files:
23
26
  - lib/messagebird/hlr.rb
24
27
  - lib/messagebird/lookup.rb
25
28
  - lib/messagebird/message.rb
26
- - lib/messagebird/otp.rb
27
29
  - lib/messagebird/recipient.rb
30
+ - lib/messagebird/verify.rb
28
31
  - lib/messagebird/voicemessage.rb
29
- - lib/messagebird.rb
30
- - LICENSE
31
- - README.md
32
32
  homepage: https://github.com/messagebird/ruby-rest-api
33
33
  licenses:
34
34
  - BSD-2-Clause
@@ -39,17 +39,17 @@ require_paths:
39
39
  - lib
40
40
  required_ruby_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - '>='
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  requirements: []
51
51
  rubyforge_project:
52
- rubygems_version: 2.0.14.1
52
+ rubygems_version: 2.5.2
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: MessageBird's REST API