messagebird-rest 3.1.1 → 4.0.0

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
  SHA256:
3
- metadata.gz: 377efa55fd0f725542290a4a79fac960bf918bdd8bd5cad01f17dccfacbc2dc1
4
- data.tar.gz: 57616887a846b29fc83a21e3e28edc5abdb2eb54cfbbc2990389f7bb13b4dd43
3
+ metadata.gz: 7f7b235894410103a5ae0cddb620fb84e1e713c022a8f974ab54d114d69fe1d0
4
+ data.tar.gz: 95411be3e97854eb9696c0b2f24092fdbd0f41deab6949be4656566312520e01
5
5
  SHA512:
6
- metadata.gz: 79eb3dd3fee60deb9ae97411fab95c0137ad55a9bf9daf39897be39c3b71fc5891b6618b0bd23719a1d5b8cf2c7dac223d63871ef0012ff4faabcc783ce4e4f7
7
- data.tar.gz: a555a6c55b363ed6102768b803e9f884af7bd65e78dab3f41951253edf2127886f1ec690fb3709c243d0ae63aeed8adf57787cd63f79e23a64c709cda5f1a521
6
+ metadata.gz: 13e721d025a6e85b5f503770fe04a09a60048358ca9c76556a42903a7d59134f9290b2b736a6504bbfab559997bd29d53c8fd76b74b861544dd80d7de3d502d3
7
+ data.tar.gz: 26762318e8db116c1ddff86d49b64434328b0569815ab84f247c255978d7e60773e0d87f6ab589441bbcd1ab4460815734b1c42944b4425dbc998a7d11da6f23
@@ -7,6 +7,8 @@ module MessageBird
7
7
  class Base
8
8
  # takes each element from the given hash and apply it to ourselves through an assignment method
9
9
  def map_hash_elements_to_self(hash)
10
+ return if hash.nil?
11
+
10
12
  hash.each do |key, value|
11
13
  method_name = key.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase # convert came case to snake case
12
14
  method_name += '='
@@ -26,7 +26,8 @@ module MessageBird
26
26
  end
27
27
 
28
28
  class CallFlowList < List
29
- attr_accessor :perPage, :currentPage, :pageCount, :totalCount
29
+ attr_accessor :per_page, :current_page, :page_count, :total_count
30
+
30
31
  PER_PAGE = 20
31
32
  CURRENT_PAGE = 1
32
33
 
@@ -53,8 +54,8 @@ module MessageBird
53
54
 
54
55
  class CallFlowStepOption < MessageBird::Base
55
56
  attr_accessor :destination, :payload, :language, :voice, :repeat,
56
- :media, :length, :maxLength, :timeout, :finishOnKey, :transcribe,
57
- :transcribeLanguage, :record, :url, :ifMachine, :machineTimeout,
58
- :onFinish, :mask
57
+ :media, :length, :max_length, :timeout, :finish_on_key, :transcribe,
58
+ :transcribe_language, :record, :url, :if_machine, :machine_timeout,
59
+ :on_finish, :mask
59
60
  end
60
61
  end
@@ -30,14 +30,16 @@ require 'messagebird/voice/call'
30
30
  require 'messagebird/voice/call_leg'
31
31
  require 'messagebird/voice/call_leg_recording'
32
32
  require 'messagebird/voice/transcription'
33
- require 'messagebird/voice/list'
34
33
 
35
34
  module MessageBird
36
35
  class ErrorException < StandardError
37
36
  attr_reader :errors
38
37
 
39
38
  def initialize(errors)
39
+ super()
40
40
  @errors = errors
41
+ message = errors.map(&:message).join(', ')
42
+ super(message)
41
43
  end
42
44
  end
43
45
 
@@ -47,7 +49,8 @@ module MessageBird
47
49
  class Client
48
50
  attr_reader :access_key, :http_client, :conversation_client, :voice_client
49
51
 
50
- def initialize(access_key = nil, http_client = nil, conversation_client = nil, voice_client = nil)
52
+ def initialize(access_key = nil, http_client = nil, conversation_client = nil, voice_client = nil) # rubocop:disable Metrics/ParameterLists
53
+ super()
51
54
  @access_key = access_key || ENV['MESSAGEBIRD_ACCESS_KEY']
52
55
  @http_client = http_client || HttpClient.new(@access_key)
53
56
  @conversation_client = conversation_client || ConversationClient.new(@access_key)
@@ -490,7 +493,7 @@ module MessageBird
490
493
  # JSON by default. See also:
491
494
  # https://developers.messagebird.com/docs/alternatives.
492
495
 
493
- '_method=PUT&' + contact_ids.map { |id| "ids[]=#{id}" }.join('&')
496
+ contact_ids.map { |id| "ids[]=#{id}" }.join('&').prepend('_method=PUT&')
494
497
  end
495
498
 
496
499
  def add_querystring(path, params)
@@ -14,9 +14,9 @@ module MessageBird
14
14
  request.body = params.to_json
15
15
  request
16
16
  end
17
- end
18
17
 
19
- def endpoint
20
- ENDPOINT
18
+ def endpoint
19
+ ENDPOINT
20
+ end
21
21
  end
22
22
  end
@@ -5,5 +5,13 @@ require 'messagebird/base'
5
5
  module MessageBird
6
6
  class Error < MessageBird::Base
7
7
  attr_accessor :code, :description, :parameter
8
+
9
+ def message
10
+ if parameter
11
+ "#{description} (error code: #{code}, parameter: #{parameter})"
12
+ else
13
+ "#{description} (error code: #{code})"
14
+ end
15
+ end
8
16
  end
9
17
  end
@@ -33,7 +33,7 @@ module MessageBird
33
33
  http
34
34
  end
35
35
 
36
- def request(method, path, params = {}, check_json = true)
36
+ def request(method, path, params = {}, check_json: true)
37
37
  uri = URI.join(endpoint, path)
38
38
  http = build_http_client(uri)
39
39
  request = build_request(method, uri, params)
@@ -2,23 +2,25 @@
2
2
 
3
3
  require 'messagebird/base'
4
4
 
5
- class List < MessageBird::Base
6
- attr_accessor :offset, :limit, :count, :total_count, :links
7
- attr_reader :items
5
+ module MessageBird
6
+ class List < MessageBird::Base
7
+ attr_accessor :offset, :limit, :count, :total_count, :links
8
+ attr_reader :items
8
9
 
9
- # type will be used to create objects for the items, e.g.
10
- # List.new(Contact, {}).
11
- def initialize(type, json)
12
- @type = type
10
+ # type will be used to create objects for the items, e.g.
11
+ # List.new(Contact, {}).
12
+ def initialize(type, json)
13
+ @type = type
13
14
 
14
- super(json)
15
- end
15
+ super(json)
16
+ end
16
17
 
17
- def items=(value)
18
- @items = value.map { |i| @type.new i }
19
- end
18
+ def items=(value)
19
+ @items = value.map { |i| @type.new i }
20
+ end
20
21
 
21
- def [](index)
22
- @items[index]
22
+ def [](index)
23
+ @items[index]
24
+ end
23
25
  end
24
26
  end
@@ -6,7 +6,7 @@ require 'messagebird/recipient'
6
6
  module MessageBird
7
7
  class Message < MessageBird::Base
8
8
  attr_accessor :id, :href, :direction, :type, :originator, :body, :reference,
9
- :validity, :gateway, :typeDetails, :datacoding, :mclass
9
+ :validity, :gateway, :type_details, :datacoding, :mclass
10
10
  attr_reader :scheduled_date_time, :created_datetime, :recipients
11
11
 
12
12
  def scheduled_date_time=(value)
@@ -20,7 +20,7 @@ module MessageBird
20
20
  #
21
21
  # @param [string] signature_key customer signature key. Can be retrieved through <a href="https://dashboard.messagebird.com/developers/settings">Developer Settings</a>. This is NOT your API key.
22
22
  # @param [bool] skip_url_validation whether url_hash claim validation should be skipped. Note that when true, no query parameters should be trusted.
23
- def initialize(signature_key, skip_url_validation = false)
23
+ def initialize(signature_key, skip_url_validation: false)
24
24
  @signature_key = signature_key
25
25
  @skip_url_validation = skip_url_validation
26
26
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MessageBird
4
4
  module Version
5
- STRING = '3.1.1'
5
+ STRING = '4.0.0'
6
6
  end
7
7
  end
@@ -11,6 +11,7 @@ module MessageBird
11
11
 
12
12
  # further processed attributes for convenience
13
13
  attr_accessor :_links, :uri
14
+
14
15
  # Grab the URI to the downloadable file and provide it as a direct attribute
15
16
  def handle_links(links_object)
16
17
  @uri = links_object['file']
@@ -6,6 +6,7 @@ module MessageBird
6
6
  module Voice
7
7
  class List < List
8
8
  attr_accessor :per_page, :current_page, :page_count, :total_count
9
+
9
10
  PER_PAGE = 20
10
11
  CURRENT_PAGE = 1
11
12
  def data=(value)
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: 3.1.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maurice Nonnekes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-31 00:00:00.000000000 Z
11
+ date: 2022-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.3
19
+ version: 2.3.0
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: 2.2.3
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.10.0
33
+ version: 3.11.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.10.0
40
+ version: 3.11.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.77.0
47
+ version: 1.26.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.77.0
54
+ version: 1.26.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.7.5
61
+ version: 3.14.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.7.5
68
+ version: 3.14.0
69
69
  description: A simple REST API for MessageBird in Ruby
70
70
  email: maurice@messagebird.com
71
71
  executables: []
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '2.0'
131
+ version: '3.0'
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - ">="