messagebird-rest 4.0.0 → 5.0.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 +4 -4
- data/README.md +9 -8
- data/lib/messagebird/client.rb +2 -2
- data/lib/messagebird/request_validator.rb +12 -2
- data/lib/messagebird/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb20303b6fdb4eb301b53bd6423e5f0398bd2f74037f53794bb91b09bb0da975
|
4
|
+
data.tar.gz: 201337fdad3472b79cd83fab56def8bcbd503b04a223e414ad4c9098bd5eaac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fca6980452a534999802b252f07a88fac2b282087cbe40499c88a4b69370eea8172fda5fba0a3282c8dbceaad4857916a69ad2722872f6623a441d5ff5cddcf7
|
7
|
+
data.tar.gz: f0c5f96a9ab18e83291b4ed81758d6fb704b34e01d2c69f8135f77e216af6a00aed266c134b632386c13c976da823f0a8a2dccec71e1499e3e3655034a6d4715
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ MessageBird's REST API for Ruby
|
|
2
2
|
===============================
|
3
3
|
This repository contains the open source Ruby client for MessageBird's REST API. Documentation can be found at: https://developers.messagebird.com/
|
4
4
|
|
5
|
-
[](https://github.com/messagebird/ruby-rest-api/actions)
|
6
6
|
|
7
7
|
Requirements
|
8
8
|
------------
|
@@ -15,10 +15,11 @@ Installation
|
|
15
15
|
You can either include the following line in your Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem 'messagebird-rest', :
|
18
|
+
gem 'messagebird-rest', require: 'messagebird'
|
19
19
|
```
|
20
20
|
|
21
21
|
Or you can just manually install it from the command line:
|
22
|
+
|
22
23
|
```sh
|
23
24
|
$ gem install messagebird-rest
|
24
25
|
```
|
@@ -28,7 +29,7 @@ Examples
|
|
28
29
|
We have put some self-explanatory examples in the *examples* directory, but here is a quick breakdown on how it works. First, you need to create an instance of **MessageBird::Client**. Be sure to replace **YOUR_ACCESS_KEY** with something real in the bottom example.
|
29
30
|
|
30
31
|
```ruby
|
31
|
-
require 'pp'
|
32
|
+
require 'pp' # Only needed for this example
|
32
33
|
require 'messagebird'
|
33
34
|
|
34
35
|
client = MessageBird::Client.new(YOUR_ACCESS_KEY)
|
@@ -54,7 +55,7 @@ Chances are that the most common use you'll have for this API client is the abil
|
|
54
55
|
Optional parameters can be specified as a hash.
|
55
56
|
|
56
57
|
```ruby
|
57
|
-
pp client.message_create('FromMe', '31612345678', 'Hello World', :
|
58
|
+
pp client.message_create('FromMe', '31612345678', 'Hello World', reference: 'MyReference')
|
58
59
|
|
59
60
|
#<MessageBird::Message:0x007f8d5b883520
|
60
61
|
@body="Hello World",
|
@@ -118,7 +119,7 @@ You can send and verify One-Time Passwords through the MessageBird API using the
|
|
118
119
|
|
119
120
|
```ruby
|
120
121
|
# verify_create requires a recipient as a required parameter, and other optional paramaters
|
121
|
-
client.verify_create(31612345678,
|
122
|
+
client.verify_create(31612345678, reference: "YourReference")
|
122
123
|
|
123
124
|
#<MessageBird::Verify:0x007fb3c18c8148
|
124
125
|
@id="080b7f804555213678f14f6o24607735",
|
@@ -143,7 +144,7 @@ MessageBird also offers the ability to send out a text message as a voice messag
|
|
143
144
|
Optional parameters can be specified as a hash.
|
144
145
|
|
145
146
|
```ruby
|
146
|
-
pp client.voice_message_create('31612345678', 'Hello World', :
|
147
|
+
pp client.voice_message_create('31612345678', 'Hello World', reference: 'MyReference')
|
147
148
|
|
148
149
|
#<MessageBird::VoiceMessage:0x000001030101b8
|
149
150
|
@body="Hello World",
|
@@ -179,7 +180,7 @@ client.voice_message('a08e51a0353bd16cea7f298a37405850')
|
|
179
180
|
There is also a Numbers API that allow you to search for and purchase number subscriptions to use as originator in other services.
|
180
181
|
|
181
182
|
```ruby
|
182
|
-
pp client.number_search("NL",
|
183
|
+
pp client.number_search("NL", limit: 52)
|
183
184
|
|
184
185
|
#<List:0x00007fa405130618
|
185
186
|
@count=5,
|
@@ -230,4 +231,4 @@ Complete documentation, instructions, and examples are available at:
|
|
230
231
|
|
231
232
|
License
|
232
233
|
-------
|
233
|
-
The MessageBird REST Client for Ruby is licensed under [The BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause). Copyright (c)
|
234
|
+
The MessageBird REST Client for Ruby is licensed under [The BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause). Copyright (c) 2025, MessageBird
|
data/lib/messagebird/client.rb
CHANGED
@@ -460,13 +460,13 @@ module MessageBird
|
|
460
460
|
number_request(:delete, "phone-numbers/#{number}")
|
461
461
|
end
|
462
462
|
|
463
|
-
def call_flow_create(
|
463
|
+
def call_flow_create(steps, default, record, params = {})
|
464
464
|
params = params.merge(
|
465
|
-
title: title,
|
466
465
|
steps: steps,
|
467
466
|
default: default,
|
468
467
|
record: record
|
469
468
|
)
|
469
|
+
|
470
470
|
CallFlow.new(voice_request(:post, 'call-flows', params))
|
471
471
|
end
|
472
472
|
|
@@ -71,14 +71,14 @@ module MessageBird
|
|
71
71
|
|
72
72
|
def validate_url(url, url_hash)
|
73
73
|
expected_url_hash = Digest::SHA256.hexdigest url
|
74
|
-
unless
|
74
|
+
unless secure_compare(expected_url_hash, url_hash)
|
75
75
|
raise ValidationError, 'invalid jwt: claim url_hash is invalid'
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
def validate_payload(body, payload_hash)
|
80
80
|
if !body.to_s.empty? && !payload_hash.to_s.empty?
|
81
|
-
unless
|
81
|
+
unless secure_compare(Digest::SHA256.hexdigest(body), payload_hash)
|
82
82
|
raise ValidationError, 'invalid jwt: claim payload_hash is invalid'
|
83
83
|
end
|
84
84
|
elsif !body.to_s.empty?
|
@@ -87,5 +87,15 @@ module MessageBird
|
|
87
87
|
raise ValidationError, 'invalid jwt: claim payload_hash is set but actual payload is missing'
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
# Adaption of https://github.com/rails/rails/blob/cf6ff17e9a3c6c1139040b519a341f55f0be16cf/activesupport/lib/active_support/security_utils.rb#L33
|
92
|
+
# Copied here so as to avoid adding a dependency on ActiveSupport to this gem
|
93
|
+
#
|
94
|
+
# Note that unlike `fixed_length_secure_compare` in the above url we don't fall back to a custom implementation
|
95
|
+
# of fixed_length_secure_compare, since OpenSSL.fixed_length_secure_compare is present in OpenSSL 2.2
|
96
|
+
# https://github.com/ruby/openssl/blob/master/History.md#version-220 which is included in Ruby 3.0 and above
|
97
|
+
def secure_compare(first, second)
|
98
|
+
first.bytesize == second.bytesize && OpenSSL.fixed_length_secure_compare(first, second)
|
99
|
+
end
|
90
100
|
end
|
91
101
|
end
|
data/lib/messagebird/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messagebird-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maurice Nonnekes
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,7 +120,7 @@ homepage: https://github.com/messagebird/ruby-rest-api
|
|
120
120
|
licenses:
|
121
121
|
- BSD-2-Clause
|
122
122
|
metadata: {}
|
123
|
-
post_install_message:
|
123
|
+
post_install_message:
|
124
124
|
rdoc_options: []
|
125
125
|
require_paths:
|
126
126
|
- lib
|
@@ -135,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
139
|
-
signing_key:
|
138
|
+
rubygems_version: 3.4.20
|
139
|
+
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: MessageBird's REST API
|
142
142
|
test_files: []
|