From 362f23af83b0bb7b5d9ea1624f97f9ac72b2b85e Mon Sep 17 00:00:00 2001 From: marcel corso Date: Thu, 31 Mar 2022 10:57:41 +0200 Subject: [PATCH 01/10] upgrade deps --- messagebird-rest.gemspec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/messagebird-rest.gemspec b/messagebird-rest.gemspec index 4ae55b2..e7976d3 100644 --- a/messagebird-rest.gemspec +++ b/messagebird-rest.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.name = 'messagebird-rest' s.version = MessageBird::Version::STRING s.platform = Gem::Platform::RUBY - s.required_ruby_version = '>= 2.0' + s.required_ruby_version = '>= 3.0' s.date = Time.now s.summary = "MessageBird's REST API" s.description = 'A simple REST API for MessageBird in Ruby' @@ -23,9 +23,9 @@ Gem::Specification.new do |s| s.files = Dir.glob('lib/**/*') + %w(LICENSE README.md) s.require_path = 'lib' - s.add_dependency "jwt", "~> 2.2.3" + s.add_dependency "jwt", "~> 2.3.0" - s.add_development_dependency "rspec", "~> 3.10.0" - s.add_development_dependency "rubocop", "~> 0.77.0" - s.add_development_dependency 'webmock', '~> 3.7.5' + s.add_development_dependency "rspec", "~> 3.11.0" + s.add_development_dependency "rubocop", "~> 1.26.1" + s.add_development_dependency 'webmock', '~> 3.14.0' end From adfd9935da48ffd13e440451078cbf10eca032ec Mon Sep 17 00:00:00 2001 From: marcel corso Date: Thu, 31 Mar 2022 13:35:46 +0200 Subject: [PATCH 02/10] remove old rubies --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ca8d1c..ad79fa1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - ruby-version: [ "2.7.3", "3.0.1" ] + ruby-version: [ "3.0.3", "3.1.1" ] steps: - uses: actions/checkout@v2 From a0a9941317c2cdae205d70e34a7b150ae66033c3 Mon Sep 17 00:00:00 2001 From: marcel corso Date: Thu, 31 Mar 2022 16:28:38 +0200 Subject: [PATCH 03/10] upgrade ruby expectations for rubocop and fix all of the issues --- .rubocop.yml | 7 +- examples/balance.rb | 2 +- examples/call.rb | 2 +- examples/call_leg_recordings.rb | 2 +- examples/call_legs.rb | 2 +- examples/contact_create.rb | 2 +- examples/contact_list.rb | 2 +- examples/conversation.rb | 2 +- examples/conversation_list.rb | 2 +- examples/conversation_message.rb | 2 +- examples/conversation_messages_list.rb | 2 +- examples/conversation_reply.rb | 2 +- examples/conversation_update.rb | 2 +- examples/conversation_webhook.rb | 2 +- examples/conversation_webhook_create.rb | 2 +- examples/conversation_webhook_delete.rb | 2 +- examples/conversation_webhook_update.rb | 2 +- examples/conversation_webhooks_list.rb | 2 +- examples/group_create.rb | 2 +- examples/group_list.rb | 2 +- examples/hlr.rb | 2 +- examples/hlr_create.rb | 2 +- examples/lookup.rb | 2 +- examples/lookup_hlr.rb | 2 +- examples/lookup_hlr_create.rb | 2 +- examples/message.rb | 2 +- examples/message_create.rb | 2 +- examples/message_list.rb | 2 +- examples/number_cancel.rb | 2 +- examples/number_fetch.rb | 2 +- examples/number_fetch_all.rb | 2 +- examples/number_purchase.rb | 2 +- examples/number_search.rb | 2 +- examples/number_update.rb | 2 +- examples/send_conversation_message.rb | 2 +- examples/signed_request_validation.rb | 2 +- examples/start_conversation.rb | 2 +- examples/start_hsm_conversation.rb | 2 +- examples/verify.rb | 2 +- examples/verify_create.rb | 2 +- examples/verify_create_email.rb | 2 +- examples/verify_delete.rb | 2 +- examples/verify_email_message.rb | 2 +- examples/verify_token.rb | 2 +- examples/voice_message.rb | 2 +- examples/voice_message_create.rb | 2 +- examples/voice_transcription.rb | 2 +- examples/voice_webhook_create.rb | 2 +- examples/voice_webhook_delete.rb | 2 +- examples/voice_webhook_update.rb | 2 +- examples/voice_webhooks_list.rb | 2 +- lib/messagebird/callflow.rb | 9 +- lib/messagebird/client.rb | 61 ++++++------ lib/messagebird/http_client.rb | 2 +- lib/messagebird/message.rb | 2 +- lib/messagebird/request_validator.rb | 2 +- lib/messagebird/voice/call_leg_recording.rb | 1 + lib/messagebird/voice/list.rb | 1 + spec/call_flow_spec.rb | 4 +- spec/call_spec.rb | 104 ++++++++++---------- 60 files changed, 148 insertions(+), 145 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d4db141..532ca39 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,6 @@ AllCops: - TargetRubyVersion: 2.6.7 + NewCops: enable + TargetRubyVersion: 3.1.1 # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop # to ignore them, so only the ones explicitly set in this file are enabled. # DisabledByDefault: true @@ -11,7 +12,7 @@ Metrics/ClassLength: Enabled: false Metrics/MethodLength: Enabled: false -Metrics/LineLength: +Layout/LineLength: Enabled: false Metrics/AbcSize: Enabled: false @@ -35,5 +36,3 @@ Style/PercentLiteralDelimiters: Enabled: false Style/SymbolArray: Enabled: false -Style/BracesAroundHashParameters: - Enabled: false diff --git a/examples/balance.rb b/examples/balance.rb index 0201efb..a45873a 100755 --- a/examples/balance.rb +++ b/examples/balance.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'test_gshuPaZoeEG6ovbc8M79w0QyM' diff --git a/examples/call.rb b/examples/call.rb index 2feea25..1c8179e 100755 --- a/examples/call.rb +++ b/examples/call.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'YOUR ACCESS KEY HERE' diff --git a/examples/call_leg_recordings.rb b/examples/call_leg_recordings.rb index 288b451..d403585 100755 --- a/examples/call_leg_recordings.rb +++ b/examples/call_leg_recordings.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/call_legs.rb b/examples/call_legs.rb index b46139e..f85816b 100755 --- a/examples/call_legs.rb +++ b/examples/call_legs.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'YOUR ACCESS KEY HERE' diff --git a/examples/contact_create.rb b/examples/contact_create.rb index bd6a4a9..2bdda8c 100755 --- a/examples/contact_create.rb +++ b/examples/contact_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/contact_list.rb b/examples/contact_list.rb index 22ce004..a8c4af3 100755 --- a/examples/contact_list.rb +++ b/examples/contact_list.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/conversation.rb b/examples/conversation.rb index 0dbff2e..6aed36b 100755 --- a/examples/conversation.rb +++ b/examples/conversation.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_list.rb b/examples/conversation_list.rb index 4655d97..dc96351 100755 --- a/examples/conversation_list.rb +++ b/examples/conversation_list.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_message.rb b/examples/conversation_message.rb index aa93e73..14d4018 100755 --- a/examples/conversation_message.rb +++ b/examples/conversation_message.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_messages_list.rb b/examples/conversation_messages_list.rb index b981c62..ac8f81c 100755 --- a/examples/conversation_messages_list.rb +++ b/examples/conversation_messages_list.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_reply.rb b/examples/conversation_reply.rb index 0ba94c1..9f369f2 100755 --- a/examples/conversation_reply.rb +++ b/examples/conversation_reply.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_update.rb b/examples/conversation_update.rb index fc09791..399b617 100755 --- a/examples/conversation_update.rb +++ b/examples/conversation_update.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_webhook.rb b/examples/conversation_webhook.rb index f7b6cbb..09cd6b8 100755 --- a/examples/conversation_webhook.rb +++ b/examples/conversation_webhook.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_webhook_create.rb b/examples/conversation_webhook_create.rb index 87a8c5a..ea57bbf 100755 --- a/examples/conversation_webhook_create.rb +++ b/examples/conversation_webhook_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_webhook_delete.rb b/examples/conversation_webhook_delete.rb index e248151..5c7d5b3 100755 --- a/examples/conversation_webhook_delete.rb +++ b/examples/conversation_webhook_delete.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_webhook_update.rb b/examples/conversation_webhook_update.rb index 08d4f06..bd16005 100755 --- a/examples/conversation_webhook_update.rb +++ b/examples/conversation_webhook_update.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/conversation_webhooks_list.rb b/examples/conversation_webhooks_list.rb index 1476fb8..6c6b109 100755 --- a/examples/conversation_webhooks_list.rb +++ b/examples/conversation_webhooks_list.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/group_create.rb b/examples/group_create.rb index aa14e20..8c72812 100755 --- a/examples/group_create.rb +++ b/examples/group_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/group_list.rb b/examples/group_list.rb index aee3f34..3741f81 100755 --- a/examples/group_list.rb +++ b/examples/group_list.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/hlr.rb b/examples/hlr.rb index d276c1a..ecd38f9 100755 --- a/examples/hlr.rb +++ b/examples/hlr.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/hlr_create.rb b/examples/hlr_create.rb index 9bbe526..c2e3e07 100755 --- a/examples/hlr_create.rb +++ b/examples/hlr_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'test_gshuPaZoeEG6ovbc8M79w0QyM' diff --git a/examples/lookup.rb b/examples/lookup.rb index 094501f..3c63913 100755 --- a/examples/lookup.rb +++ b/examples/lookup.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/lookup_hlr.rb b/examples/lookup_hlr.rb index 7083af7..49d7b41 100755 --- a/examples/lookup_hlr.rb +++ b/examples/lookup_hlr.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/lookup_hlr_create.rb b/examples/lookup_hlr_create.rb index c34fad1..d8ba9d1 100755 --- a/examples/lookup_hlr_create.rb +++ b/examples/lookup_hlr_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/message.rb b/examples/message.rb index d9a83ea..2364002 100755 --- a/examples/message.rb +++ b/examples/message.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/message_create.rb b/examples/message_create.rb index 7350762..3f66f8c 100755 --- a/examples/message_create.rb +++ b/examples/message_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'test_gshuPaZoeEG6ovbc8M79w0QyM' diff --git a/examples/message_list.rb b/examples/message_list.rb index 6d3d6d2..127a70b 100755 --- a/examples/message_list.rb +++ b/examples/message_list.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/number_cancel.rb b/examples/number_cancel.rb index 0be9764..30f2296 100755 --- a/examples/number_cancel.rb +++ b/examples/number_cancel.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/number_fetch.rb b/examples/number_fetch.rb index 188faa2..19349b4 100755 --- a/examples/number_fetch.rb +++ b/examples/number_fetch.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/number_fetch_all.rb b/examples/number_fetch_all.rb index 45874f4..63c154a 100755 --- a/examples/number_fetch_all.rb +++ b/examples/number_fetch_all.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/number_purchase.rb b/examples/number_purchase.rb index 1e566d3..6e00432 100755 --- a/examples/number_purchase.rb +++ b/examples/number_purchase.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/number_search.rb b/examples/number_search.rb index 07813ab..a198dcb 100755 --- a/examples/number_search.rb +++ b/examples/number_search.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/number_update.rb b/examples/number_update.rb index 82fc30c..845f199 100755 --- a/examples/number_update.rb +++ b/examples/number_update.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = 'YOUR KEY HERE' diff --git a/examples/send_conversation_message.rb b/examples/send_conversation_message.rb index 3ebc72f..e90c356 100755 --- a/examples/send_conversation_message.rb +++ b/examples/send_conversation_message.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/signed_request_validation.rb b/examples/signed_request_validation.rb index 7518ffb..21fe884 100755 --- a/examples/signed_request_validation.rb +++ b/examples/signed_request_validation.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' SIGNING_KEY = 'PlLrKaqvZNRR5zAjm42ZT6q1SQxgbbGd' diff --git a/examples/start_conversation.rb b/examples/start_conversation.rb index 6eedd56..896ad15 100755 --- a/examples/start_conversation.rb +++ b/examples/start_conversation.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/start_hsm_conversation.rb b/examples/start_hsm_conversation.rb index 5eae298..3d71407 100755 --- a/examples/start_hsm_conversation.rb +++ b/examples/start_hsm_conversation.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/verify.rb b/examples/verify.rb index b5feda1..363a847 100755 --- a/examples/verify.rb +++ b/examples/verify.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/verify_create.rb b/examples/verify_create.rb index 9de3b7a..12eb488 100755 --- a/examples/verify_create.rb +++ b/examples/verify_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/verify_create_email.rb b/examples/verify_create_email.rb index db80ad6..fa128a9 100755 --- a/examples/verify_create_email.rb +++ b/examples/verify_create_email.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/verify_delete.rb b/examples/verify_delete.rb index 32564f6..fd00c12 100755 --- a/examples/verify_delete.rb +++ b/examples/verify_delete.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/verify_email_message.rb b/examples/verify_email_message.rb index e60f393..872f355 100755 --- a/examples/verify_email_message.rb +++ b/examples/verify_email_message.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/verify_token.rb b/examples/verify_token.rb index 8c90ea4..84d5449 100755 --- a/examples/verify_token.rb +++ b/examples/verify_token.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/voice_message.rb b/examples/voice_message.rb index 61d6d0c..c2f3499 100755 --- a/examples/voice_message.rb +++ b/examples/voice_message.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/voice_message_create.rb b/examples/voice_message_create.rb index a8af255..b9f050e 100755 --- a/examples/voice_message_create.rb +++ b/examples/voice_message_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'test_gshuPaZoeEG6ovbc8M79w0QyM' diff --git a/examples/voice_transcription.rb b/examples/voice_transcription.rb index ddb436d..fb75bf9 100755 --- a/examples/voice_transcription.rb +++ b/examples/voice_transcription.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' ACCESS_KEY = 'test_gshuPaZoeEG6ovbc8M79w0QyM' diff --git a/examples/voice_webhook_create.rb b/examples/voice_webhook_create.rb index b27262f..9a9859a 100755 --- a/examples/voice_webhook_create.rb +++ b/examples/voice_webhook_create.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/voice_webhook_delete.rb b/examples/voice_webhook_delete.rb index d2b4b06..fb05df4 100755 --- a/examples/voice_webhook_delete.rb +++ b/examples/voice_webhook_delete.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/voice_webhook_update.rb b/examples/voice_webhook_update.rb index 5a06076..4e87cca 100755 --- a/examples/voice_webhook_update.rb +++ b/examples/voice_webhook_update.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/examples/voice_webhooks_list.rb b/examples/voice_webhooks_list.rb index 4b555e4..f63e7f6 100755 --- a/examples/voice_webhooks_list.rb +++ b/examples/voice_webhooks_list.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib/') +$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib/") require 'messagebird' # ACCESS_KEY = '' diff --git a/lib/messagebird/callflow.rb b/lib/messagebird/callflow.rb index b0b3acf..937d2f3 100644 --- a/lib/messagebird/callflow.rb +++ b/lib/messagebird/callflow.rb @@ -26,7 +26,8 @@ def updated_at=(value) end class CallFlowList < List - attr_accessor :perPage, :currentPage, :pageCount, :totalCount + attr_accessor :per_page, :current_page, :page_count, :total_count + PER_PAGE = 20 CURRENT_PAGE = 1 @@ -53,8 +54,8 @@ def options=(json) class CallFlowStepOption < MessageBird::Base attr_accessor :destination, :payload, :language, :voice, :repeat, - :media, :length, :maxLength, :timeout, :finishOnKey, :transcribe, - :transcribeLanguage, :record, :url, :ifMachine, :machineTimeout, - :onFinish, :mask + :media, :length, :max_length, :timeout, :finish_on_key, :transcribe, + :transcribe_language, :record, :url, :if_machine, :machine_timeout, + :on_finish, :mask end end diff --git a/lib/messagebird/client.rb b/lib/messagebird/client.rb index 2b833cd..30dcfaa 100644 --- a/lib/messagebird/client.rb +++ b/lib/messagebird/client.rb @@ -30,13 +30,13 @@ require 'messagebird/voice/call_leg' require 'messagebird/voice/call_leg_recording' require 'messagebird/voice/transcription' -require 'messagebird/voice/list' module MessageBird class ErrorException < StandardError attr_reader :errors def initialize(errors) + super() @errors = errors end end @@ -47,7 +47,8 @@ class InvalidFeatureException < StandardError class Client attr_reader :access_key, :http_client, :conversation_client, :voice_client - def initialize(access_key = nil, http_client = nil, conversation_client = nil, voice_client = nil) + def initialize(access_key = nil, http_client = nil, conversation_client = nil, voice_client = nil) # rubocop:disable Metrics/ParameterLists + super() @access_key = access_key || ENV['MESSAGEBIRD_ACCESS_KEY'] @http_client = http_client || HttpClient.new(@access_key) @conversation_client = conversation_client || ConversationClient.new(@access_key) @@ -100,8 +101,8 @@ def send_conversation_message(from, to, params = {}) ConversationMessage.new(conversation_request( :post, 'send', - params.merge(from: from, - to: to) + params.merge(from:, + to:) )) end @@ -110,8 +111,8 @@ def start_conversation(to, channel_id, params = {}) Conversation.new(conversation_request( :post, 'conversations/start', - params.merge(to: to, - channel_id: channel_id) + params.merge(to:, + channel_id:) )) end @@ -133,7 +134,7 @@ def conversation(id) end def conversation_update(id, status) - Conversation.new(conversation_request(:patch, "conversations/#{id}", status: status)) + Conversation.new(conversation_request(:patch, "conversations/#{id}", status:)) end def conversation_reply(id, params = {}) @@ -161,9 +162,9 @@ def conversation_webhook_create(channel_id, url, events = []) ConversationWebhook.new(conversation_request( :post, 'webhooks', - channel_id: channel_id, - url: url, - events: events + channel_id:, + url:, + events: )) end @@ -198,8 +199,8 @@ def hlr_create(msisdn, reference) HLR.new(request( :post, 'hlr', - msisdn: msisdn, - reference: reference + msisdn:, + reference: )) end @@ -218,7 +219,7 @@ def verify_create(recipient, params = {}) Verify.new(request( :post, 'verify', - params.merge(recipient: recipient) + params.merge(recipient:) )) end @@ -255,7 +256,7 @@ def message_create(originator, recipients, body, params = {}) 'messages', params.merge(originator: originator.to_s, body: body.to_s, - recipients: recipients) + recipients:) )) end @@ -272,12 +273,12 @@ def voice_message_create(recipients, body, params = {}) VoiceMessage.new(request( :post, 'voicemessages', - params.merge(recipients: recipients, body: body.to_s) + params.merge(recipients:, body: body.to_s) )) end def voice_webhook_create(url, params = {}) - Voice::Webhook.new(voice_request(:post, 'webhooks', params.merge(url: url))) + Voice::Webhook.new(voice_request(:post, 'webhooks', params.merge(url:))) end def voice_webhooks_list(per_page = VoiceList::PER_PAGE, page = VoiceList::CURRENT_PAGE) @@ -300,7 +301,7 @@ def call_create(source, destination, call_flow = {}, webhook = {}, params = {}) params = params.merge(callFlow: call_flow.to_json) unless call_flow.empty? params = params.merge(webhook: webhook.to_json) unless webhook.empty? - Voice::Call.new(voice_request(:post, 'calls', params.merge(source: source, destination: destination))) + Voice::Call.new(voice_request(:post, 'calls', params.merge(source:, destination:))) end def call_list(per_page = Voice::List::PER_PAGE, page = Voice::List::CURRENT_PAGE) @@ -331,8 +332,8 @@ def call_leg_recording_delete(call_id, leg_id, recording_id) voice_request(:delete, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}") end - def call_leg_recording_download(recording_uri, &block) - @voice_client.request_block(:get, recording_uri, {}, &block) + def call_leg_recording_download(recording_uri, &) + @voice_client.request_block(:get, recording_uri, {}, &) end def voice_transcription_create(call_id, leg_id, recording_id, params = {}) @@ -343,8 +344,8 @@ def voice_transcriptions_list(call_id, leg_id, recording_id) Voice::List.new(Voice::Transcription, voice_request(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions")) end - def voice_transcription_download(call_id, leg_id, recording_id, transcription_id, &block) - @voice_client.request_block(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt", {}, &block) + def voice_transcription_download(call_id, leg_id, recording_id, transcription_id, &) + @voice_client.request_block(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt", {}, &) end def voice_transcription_view(call_id, leg_id, recording_id, transcription_id) @@ -392,7 +393,7 @@ def group(id) end def group_create(name) - Group.new(request(:post, 'groups', name: name)) + Group.new(request(:post, 'groups', name:)) end def group_delete(id) @@ -404,7 +405,7 @@ def group_list(limit = 0, offset = 0) end def group_update(id, name) - request(:patch, "groups/#{id}", name: name) + request(:patch, "groups/#{id}", name:) end def group_add_contacts(group_id, contact_ids) @@ -429,7 +430,7 @@ def number_search(country_code, params = {}) # Purchase an avaiable number def number_purchase(number, country_code, billing_interval_months) params = { - number: number, + number:, countryCode: country_code, billingIntervalMonths: billing_interval_months } @@ -449,7 +450,7 @@ def number_fetch(number) # Update a number def number_update(number, tags) tags = [tags] if tags.is_a? String - Number.new(number_request(:patch, "phone-numbers/#{number}", tags: tags)) + Number.new(number_request(:patch, "phone-numbers/#{number}", tags:)) end # Cancel a number @@ -459,10 +460,10 @@ def number_cancel(number) def call_flow_create(title, steps, default, record, params = {}) params = params.merge( - title: title, - steps: steps, - default: default, - record: record + title:, + steps:, + default:, + record: ) CallFlow.new(voice_request(:post, 'call-flows', params)) end @@ -490,7 +491,7 @@ def add_contacts_query(contact_ids) # JSON by default. See also: # https://developers.messagebird.com/docs/alternatives. - '_method=PUT&' + contact_ids.map { |id| "ids[]=#{id}" }.join('&') + '_method=PUT&' + contact_ids.map { |id| "ids[]=#{id}" }.join('&') # rubocop:disable Style/StringConcatenation end def add_querystring(path, params) diff --git a/lib/messagebird/http_client.rb b/lib/messagebird/http_client.rb index 647b842..038d054 100644 --- a/lib/messagebird/http_client.rb +++ b/lib/messagebird/http_client.rb @@ -33,7 +33,7 @@ def build_http_client(uri) http end - def request(method, path, params = {}, check_json = true) + def request(method, path, params = {}, check_json: true) uri = URI.join(endpoint, path) http = build_http_client(uri) request = build_request(method, uri, params) diff --git a/lib/messagebird/message.rb b/lib/messagebird/message.rb index fa9fc46..11957f6 100644 --- a/lib/messagebird/message.rb +++ b/lib/messagebird/message.rb @@ -6,7 +6,7 @@ module MessageBird class Message < MessageBird::Base attr_accessor :id, :href, :direction, :type, :originator, :body, :reference, - :validity, :gateway, :typeDetails, :datacoding, :mclass + :validity, :gateway, :type_details, :datacoding, :mclass attr_reader :scheduled_date_time, :created_datetime, :recipients def scheduled_date_time=(value) diff --git a/lib/messagebird/request_validator.rb b/lib/messagebird/request_validator.rb index 4b7887e..e1955a2 100644 --- a/lib/messagebird/request_validator.rb +++ b/lib/messagebird/request_validator.rb @@ -20,7 +20,7 @@ class RequestValidator # # @param [string] signature_key customer signature key. Can be retrieved through Developer Settings. This is NOT your API key. # @param [bool] skip_url_validation whether url_hash claim validation should be skipped. Note that when true, no query parameters should be trusted. - def initialize(signature_key, skip_url_validation = false) + def initialize(signature_key, skip_url_validation: false) @signature_key = signature_key @skip_url_validation = skip_url_validation end diff --git a/lib/messagebird/voice/call_leg_recording.rb b/lib/messagebird/voice/call_leg_recording.rb index 4006a2a..b0d6dc0 100644 --- a/lib/messagebird/voice/call_leg_recording.rb +++ b/lib/messagebird/voice/call_leg_recording.rb @@ -11,6 +11,7 @@ class CallLegRecording < MessageBird::Voice::Base # further processed attributes for convenience attr_accessor :_links, :uri + # Grab the URI to the downloadable file and provide it as a direct attribute def handle_links(links_object) @uri = links_object['file'] diff --git a/lib/messagebird/voice/list.rb b/lib/messagebird/voice/list.rb index 9cda249..b1a0414 100644 --- a/lib/messagebird/voice/list.rb +++ b/lib/messagebird/voice/list.rb @@ -6,6 +6,7 @@ module MessageBird module Voice class List < List attr_accessor :per_page, :current_page, :page_count, :total_count + PER_PAGE = 20 CURRENT_PAGE = 1 def data=(value) diff --git a/spec/call_flow_spec.rb b/spec/call_flow_spec.rb index 0ee59e4..129f955 100644 --- a/spec/call_flow_spec.rb +++ b/spec/call_flow_spec.rb @@ -23,7 +23,7 @@ data: [ { id: call_flow_id, - title: title, + title:, steps: [ { id: step_id, @@ -42,7 +42,7 @@ } expect(voice_client) .to receive(:request) - .with(:post, 'call-flows', { title: title, steps: steps, default: default, record: record }) + .with(:post, 'call-flows', { title:, steps:, default:, record: }) .and_return(mock_data.to_json) call_flow = client.call_flow_create(title, steps, default, record) diff --git a/spec/call_spec.rb b/spec/call_spec.rb index 6384f17..2e926a6 100644 --- a/spec/call_spec.rb +++ b/spec/call_spec.rb @@ -38,8 +38,8 @@ it 'create a call' do expect(voice_client) .to receive(:request) - .with(:post, 'calls', { source: source, destination: destination, callFlow: call_flow.to_json }) - .and_return('{"data":[{"id":"' + call_id + '","status":"queued","source":"' + source + '","destination":"' + destination + '","createdAt":"2019-10-11T13:02:19Z","updatedAt":"2019-10-11T13:02:19Z","endedAt":null}],"_links":{"self":"/calls/' + call_id + '"},"pagination":{"total_count":0,"pageCount":0,"currentPage":0,"perPage":0}}') + .with(:post, 'calls', { source:, destination:, callFlow: call_flow.to_json }) + .and_return("{\"data\":[{\"id\":\"#{call_id}\",\"status\":\"queued\",\"source\":\"#{source}\",\"destination\":\"#{destination}\",\"createdAt\":\"2019-10-11T13:02:19Z\",\"updatedAt\":\"2019-10-11T13:02:19Z\",\"endedAt\":null}],\"_links\":{\"self\":\"/calls/#{call_id}\"},\"pagination\":{\"total_count\":0,\"pageCount\":0,\"currentPage\":0,\"perPage\":0}}") call = client.call_create(source, destination, call_flow) expect(call.id).to eq call_id end @@ -47,8 +47,8 @@ it 'create a call with webhook' do expect(voice_client) .to receive(:request) - .with(:post, 'calls', { source: source, destination: destination, callFlow: call_flow.to_json, webhook: webhook.to_json }) - .and_return('{"data":[{"id":"' + call_id + '","status":"queued","source":"' + source + '","destination":"' + destination + '","createdAt":"2019-10-11T13:02:19Z","updatedAt":"2019-10-11T13:02:19Z","endedAt":null, "webhook":' + webhook.to_json + '}],"_links":{"self":"/calls/' + call_id + '"},"pagination":{"total_count":0,"pageCount":0,"currentPage":0,"perPage":0}}') + .with(:post, 'calls', { source:, destination:, callFlow: call_flow.to_json, webhook: webhook.to_json }) + .and_return("{\"data\":[{\"id\":\"#{call_id}\",\"status\":\"queued\",\"source\":\"#{source}\",\"destination\":\"#{destination}\",\"createdAt\":\"2019-10-11T13:02:19Z\",\"updatedAt\":\"2019-10-11T13:02:19Z\",\"endedAt\":null, \"webhook\":#{webhook.to_json}}],\"_links\":{\"self\":\"/calls/#{call_id}\"},\"pagination\":{\"total_count\":0,\"pageCount\":0,\"currentPage\":0,\"perPage\":0}}") call = client.call_create(source, destination, call_flow, webhook) expect(call.id).to eq call_id expect(call.webhook.url).to eq webhook[:url] @@ -58,7 +58,7 @@ expect(voice_client) .to receive(:request) .with(:get, 'calls?perPage=20¤tPage=1', {}) - .and_return('{ "data": [ { "id": "f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58", "status": "ended", "source": "' + source + '", "destination": "31612345678", "createdAt": "2017-02-16T10:52:00Z", "updatedAt": "2017-02-16T10:59:04Z", "endedAt": "2017-02-16T10:59:04Z", "_links": { "self": "/calls/f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58" } }, { "id": "ac07a602-dbc1-11e6-bf26-cec0c932ce01", "status": "ended", "source": "' + source + '", "destination": "31612345678", "createdAt": "2017-01-16T07:51:56Z", "updatedAt": "2017-01-16T07:55:56Z", "endedAt": "2017-01-16T07:55:56Z", "webhook": ' + webhook.to_json + ',"_links": { "self": "/calls/ac07a602-dbc1-11e6-bf26-cec0c932ce01" } } ], "_links": { "self": "/calls?page=1" }, "pagination": { "total_count": 2, "pageCount": 1, "currentPage": 1, "perPage": 10 } }') + .and_return("{ \"data\": [ { \"id\": \"f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58\", \"status\": \"ended\", \"source\": \"#{source}\", \"destination\": \"31612345678\", \"createdAt\": \"2017-02-16T10:52:00Z\", \"updatedAt\": \"2017-02-16T10:59:04Z\", \"endedAt\": \"2017-02-16T10:59:04Z\", \"_links\": { \"self\": \"/calls/f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58\" } }, { \"id\": \"ac07a602-dbc1-11e6-bf26-cec0c932ce01\", \"status\": \"ended\", \"source\": \"#{source}\", \"destination\": \"31612345678\", \"createdAt\": \"2017-01-16T07:51:56Z\", \"updatedAt\": \"2017-01-16T07:55:56Z\", \"endedAt\": \"2017-01-16T07:55:56Z\", \"webhook\": #{webhook.to_json},\"_links\": { \"self\": \"/calls/ac07a602-dbc1-11e6-bf26-cec0c932ce01\" } } ], \"_links\": { \"self\": \"/calls?page=1\" }, \"pagination\": { \"total_count\": 2, \"pageCount\": 1, \"currentPage\": 1, \"perPage\": 10 } }") list = client.call_list expect(list.items).not_to be_nil @@ -102,14 +102,14 @@ expect(voice_client) .to receive(:request) .with(:get, "calls/#{call_id}/legs?perPage=#{MessageBird::Voice::List::PER_PAGE}¤tPage=#{MessageBird::Voice::List::CURRENT_PAGE}", {}) - .and_return(' + .and_return(%( { "data": [ { - "id": "' + leg_id + '", - "callId": "' + call_id + '", - "source": "' + source + '", - "destination": "' + destination + '", + "id": "#{leg_id}", + "callId": "#{call_id}", + "source": "#{source}", + "destination": "#{destination}", "service": 1, "status": "hangup", "direction": "outgoing", @@ -121,12 +121,12 @@ "answeredAt": "2019-12-03T14:50:50Z", "endedAt": "2019-12-03T14:51:00Z", "_links": { - "self": "/calls/' + call_id + '/legs/' + leg_id + '" + "self": "/calls/#{call_id}/legs/#{leg_id}" } } ], "_links": { - "self": "/calls/' + call_id + '/legs?page=1" + "self": "/calls/#{call_id}/legs?page=1" }, "pagination": { "totalCount": 1, @@ -134,7 +134,7 @@ "currentPage": 1, "perPage": 10 } - }') + })) legs = client.call_leg_list(call_id) expect(legs[0].id).to eq leg_id @@ -144,13 +144,13 @@ expect(voice_client) .to receive(:request) .with(:get, "calls/#{call_id}/legs/#{leg_id}/recordings", {}) - .and_return(' + .and_return(%( { "data": [ { - "id": "' + recording_id + '", + "id": "#{recording_id}", "format": "wav", - "legId": "' + leg_id + '", + "legId": "#{leg_id}", "status": "done", "duration": 5, "type": "ivr", @@ -158,13 +158,13 @@ "updatedAt": "2019-12-03T14:51:00Z", "deletedAt": null, "_links": { - "file": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '.wav", - "self": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '" + "file": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}.wav", + "self": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}" } } ], "_links": { - "self": "/calls/' + call_id + '/legs/' + leg_id + '/recordings?page=1" + "self": "/calls/#{call_id}'/legs/#{leg_id}/recordings?page=1" }, "pagination": { "totalCount": 1, @@ -172,23 +172,23 @@ "currentPage": 1, "perPage": 10 } - }') + })) records = client.call_leg_recording_list(call_id, leg_id) - expect(records[0].uri).to eq '/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '.wav' + expect(records[0].uri).to eq "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}.wav" end it 'view a call recording' do expect(voice_client) .to receive(:request) .with(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}", {}) - .and_return(' + .and_return(%( { "data": [ { - "id": "' + recording_id + '", + "id": "#{recording_id}", "format": "wav", - "legId": "' + leg_id + '", + "legId": "#{leg_id}", "status": "done", "duration": 12, "type": "call", @@ -198,8 +198,8 @@ } ], "_links": { - "file": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '.wav", - "self": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '" + "file": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}.wav", + "self": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}" }, "pagination": { "totalCount": 0, @@ -207,15 +207,15 @@ "currentPage": 0, "perPage": 0 } - }') + })) recording = client.call_leg_recording_view(call_id, leg_id, recording_id) - expect(recording.uri).to eq '/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '.wav' + expect(recording.uri).to eq "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}.wav" end it 'download a call recording' do mock_response = double(Net::HTTPResponse) - recording_uri = '/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '.wav' + recording_uri = "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}.wav" expect(voice_client) .to receive(:request_block) @@ -245,23 +245,23 @@ expect(voice_client) .to receive(:request) .with(:post, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions", language.to_json) - .and_return(' + .and_return(%( { "data": [ { - "id":"' + transcription_id + '", - "recordingId":"' + recording_id + '", - "error": null,"destination":"' + destination + '", + "id":"#{transcription_id}", + "recordingId":"#{recording_id}", + "error": null,"destination":"#{destination}", "createdAt":"2017-06-20T10:03:14Z", "updatedAt": "2017-06-20T10:03:14Z" } ], "_links": { - "file": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '.txt", - "self": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '" + "file": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt", + "self": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}" }, "pagination":{"total_count":0,"pageCount":0,"currentPage":0,"perPage":0} - }') + })) transcription = client.voice_transcription_create(call_id, leg_id, recording_id, language.to_json) expect(transcription.id).to eq transcription_id end @@ -270,20 +270,20 @@ expect(voice_client) .to receive(:request) .with(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}", {}) - .and_return(' + .and_return(%( { "data": [ { - "id": "' + transcription_id + '", - "recordingId": "' + recording_id + '", + "id": "#{transcription_id}", + "recordingId": "#{recording_id}", "error": null, "createdAt": "2017-06-20T10:03:14Z", "updatedAt": "2017-06-20T10:03:14Z" } ], "_links": { - "file": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '.txt", - "self": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '" + "file": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt", + "self": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}" }, "pagination": { "totalCount": 1, @@ -291,34 +291,34 @@ "currentPage": 1, "perPage": 10 } - }') + })) transcription = client.voice_transcription_view(call_id, leg_id, recording_id, transcription_id) - expect(transcription.uri).to eq '/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '.txt' + expect(transcription.uri).to eq "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt" end it 'list transcriptions' do expect(voice_client) .to receive(:request) .with(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions", {}) - .and_return(' + .and_return(%( { "data": [ { - "id":"' + transcription_id + '", - "recordingId": "' + recording_id + '", + "id":"#{transcription_id}", + "recordingId": "#{recording_id}", "status":"done", "createdAt":"2019-12-04T16:52:51Z", "updatedAt":"2019-12-04T16:53:02Z", "legId":"00000000-0000-0000-0000-000000000000", "_links": { - "file":"/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '.txt", - "self":"/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '" + "file":"/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt", + "self":"/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}" } } ], "_links": { - "self": "/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '" + "self": "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}" }, "pagination": { "totalCount": 1, @@ -326,15 +326,15 @@ "currentPage": 1, "perPage": 10 } - }') + })) records = client.voice_transcriptions_list(call_id, leg_id, recording_id) - expect(records[0].uri).to eq '/calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '.txt' + expect(records[0].uri).to eq "/calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt" end it 'download a transcription' do mock_response = double(Net::HTTPResponse) - transcription_uri = 'calls/' + call_id + '/legs/' + leg_id + '/recordings/' + recording_id + '/transcriptions/' + transcription_id + '.txt' + transcription_uri = "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt" expect(voice_client) .to receive(:request_block) From 2deddb7db3f903ff2a6b391ec1f21364e8407014 Mon Sep 17 00:00:00 2001 From: marcel corso Date: Thu, 31 Mar 2022 16:46:08 +0200 Subject: [PATCH 04/10] rollback TargetRubyVersion: 3.0.3 --- .rubocop.yml | 2 +- lib/messagebird/client.rb | 54 +++++++++++++++++++-------------------- spec/call_flow_spec.rb | 4 +-- spec/call_spec.rb | 4 +-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 532ca39..17c3448 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ AllCops: NewCops: enable - TargetRubyVersion: 3.1.1 + TargetRubyVersion: 3.0.3 # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop # to ignore them, so only the ones explicitly set in this file are enabled. # DisabledByDefault: true diff --git a/lib/messagebird/client.rb b/lib/messagebird/client.rb index 30dcfaa..2b2bcee 100644 --- a/lib/messagebird/client.rb +++ b/lib/messagebird/client.rb @@ -101,8 +101,8 @@ def send_conversation_message(from, to, params = {}) ConversationMessage.new(conversation_request( :post, 'send', - params.merge(from:, - to:) + params.merge(from: from, + to: to) )) end @@ -111,8 +111,8 @@ def start_conversation(to, channel_id, params = {}) Conversation.new(conversation_request( :post, 'conversations/start', - params.merge(to:, - channel_id:) + params.merge(to: to, + channel_id: channel_id) )) end @@ -134,7 +134,7 @@ def conversation(id) end def conversation_update(id, status) - Conversation.new(conversation_request(:patch, "conversations/#{id}", status:)) + Conversation.new(conversation_request(:patch, "conversations/#{id}", status: status)) end def conversation_reply(id, params = {}) @@ -162,9 +162,9 @@ def conversation_webhook_create(channel_id, url, events = []) ConversationWebhook.new(conversation_request( :post, 'webhooks', - channel_id:, - url:, - events: + channel_id: channel_id, + url: url, + events: events )) end @@ -199,8 +199,8 @@ def hlr_create(msisdn, reference) HLR.new(request( :post, 'hlr', - msisdn:, - reference: + msisdn: msisdn, + reference: reference )) end @@ -219,7 +219,7 @@ def verify_create(recipient, params = {}) Verify.new(request( :post, 'verify', - params.merge(recipient:) + params.merge(recipient: recipient) )) end @@ -256,7 +256,7 @@ def message_create(originator, recipients, body, params = {}) 'messages', params.merge(originator: originator.to_s, body: body.to_s, - recipients:) + recipients: recipients) )) end @@ -273,12 +273,12 @@ def voice_message_create(recipients, body, params = {}) VoiceMessage.new(request( :post, 'voicemessages', - params.merge(recipients:, body: body.to_s) + params.merge(recipients: recipients, body: body.to_s) )) end def voice_webhook_create(url, params = {}) - Voice::Webhook.new(voice_request(:post, 'webhooks', params.merge(url:))) + Voice::Webhook.new(voice_request(:post, 'webhooks', params.merge(url: url))) end def voice_webhooks_list(per_page = VoiceList::PER_PAGE, page = VoiceList::CURRENT_PAGE) @@ -301,7 +301,7 @@ def call_create(source, destination, call_flow = {}, webhook = {}, params = {}) params = params.merge(callFlow: call_flow.to_json) unless call_flow.empty? params = params.merge(webhook: webhook.to_json) unless webhook.empty? - Voice::Call.new(voice_request(:post, 'calls', params.merge(source:, destination:))) + Voice::Call.new(voice_request(:post, 'calls', params.merge(source: source, destination: destination))) end def call_list(per_page = Voice::List::PER_PAGE, page = Voice::List::CURRENT_PAGE) @@ -332,8 +332,8 @@ def call_leg_recording_delete(call_id, leg_id, recording_id) voice_request(:delete, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}") end - def call_leg_recording_download(recording_uri, &) - @voice_client.request_block(:get, recording_uri, {}, &) + def call_leg_recording_download(recording_uri, &block) + @voice_client.request_block(:get, recording_uri, {}, &block) end def voice_transcription_create(call_id, leg_id, recording_id, params = {}) @@ -344,8 +344,8 @@ def voice_transcriptions_list(call_id, leg_id, recording_id) Voice::List.new(Voice::Transcription, voice_request(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions")) end - def voice_transcription_download(call_id, leg_id, recording_id, transcription_id, &) - @voice_client.request_block(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt", {}, &) + def voice_transcription_download(call_id, leg_id, recording_id, transcription_id, &block) + @voice_client.request_block(:get, "calls/#{call_id}/legs/#{leg_id}/recordings/#{recording_id}/transcriptions/#{transcription_id}.txt", {}, &block) end def voice_transcription_view(call_id, leg_id, recording_id, transcription_id) @@ -393,7 +393,7 @@ def group(id) end def group_create(name) - Group.new(request(:post, 'groups', name:)) + Group.new(request(:post, 'groups', name: name)) end def group_delete(id) @@ -405,7 +405,7 @@ def group_list(limit = 0, offset = 0) end def group_update(id, name) - request(:patch, "groups/#{id}", name:) + request(:patch, "groups/#{id}", name: name) end def group_add_contacts(group_id, contact_ids) @@ -430,7 +430,7 @@ def number_search(country_code, params = {}) # Purchase an avaiable number def number_purchase(number, country_code, billing_interval_months) params = { - number:, + number: number, countryCode: country_code, billingIntervalMonths: billing_interval_months } @@ -450,7 +450,7 @@ def number_fetch(number) # Update a number def number_update(number, tags) tags = [tags] if tags.is_a? String - Number.new(number_request(:patch, "phone-numbers/#{number}", tags:)) + Number.new(number_request(:patch, "phone-numbers/#{number}", tags: tags)) end # Cancel a number @@ -460,10 +460,10 @@ def number_cancel(number) def call_flow_create(title, steps, default, record, params = {}) params = params.merge( - title:, - steps:, - default:, - record: + title: title, + steps: steps, + default: default, + record: record ) CallFlow.new(voice_request(:post, 'call-flows', params)) end diff --git a/spec/call_flow_spec.rb b/spec/call_flow_spec.rb index 129f955..0ee59e4 100644 --- a/spec/call_flow_spec.rb +++ b/spec/call_flow_spec.rb @@ -23,7 +23,7 @@ data: [ { id: call_flow_id, - title:, + title: title, steps: [ { id: step_id, @@ -42,7 +42,7 @@ } expect(voice_client) .to receive(:request) - .with(:post, 'call-flows', { title:, steps:, default:, record: }) + .with(:post, 'call-flows', { title: title, steps: steps, default: default, record: record }) .and_return(mock_data.to_json) call_flow = client.call_flow_create(title, steps, default, record) diff --git a/spec/call_spec.rb b/spec/call_spec.rb index 2e926a6..b6a83dc 100644 --- a/spec/call_spec.rb +++ b/spec/call_spec.rb @@ -38,7 +38,7 @@ it 'create a call' do expect(voice_client) .to receive(:request) - .with(:post, 'calls', { source:, destination:, callFlow: call_flow.to_json }) + .with(:post, 'calls', { source: source, destination: destination, callFlow: call_flow.to_json }) .and_return("{\"data\":[{\"id\":\"#{call_id}\",\"status\":\"queued\",\"source\":\"#{source}\",\"destination\":\"#{destination}\",\"createdAt\":\"2019-10-11T13:02:19Z\",\"updatedAt\":\"2019-10-11T13:02:19Z\",\"endedAt\":null}],\"_links\":{\"self\":\"/calls/#{call_id}\"},\"pagination\":{\"total_count\":0,\"pageCount\":0,\"currentPage\":0,\"perPage\":0}}") call = client.call_create(source, destination, call_flow) expect(call.id).to eq call_id @@ -47,7 +47,7 @@ it 'create a call with webhook' do expect(voice_client) .to receive(:request) - .with(:post, 'calls', { source:, destination:, callFlow: call_flow.to_json, webhook: webhook.to_json }) + .with(:post, 'calls', { source: source, destination: destination, callFlow: call_flow.to_json, webhook: webhook.to_json }) .and_return("{\"data\":[{\"id\":\"#{call_id}\",\"status\":\"queued\",\"source\":\"#{source}\",\"destination\":\"#{destination}\",\"createdAt\":\"2019-10-11T13:02:19Z\",\"updatedAt\":\"2019-10-11T13:02:19Z\",\"endedAt\":null, \"webhook\":#{webhook.to_json}}],\"_links\":{\"self\":\"/calls/#{call_id}\"},\"pagination\":{\"total_count\":0,\"pageCount\":0,\"currentPage\":0,\"perPage\":0}}") call = client.call_create(source, destination, call_flow, webhook) expect(call.id).to eq call_id From 3818b8b56ba32a609275a084092832d44382e14d Mon Sep 17 00:00:00 2001 From: marcel corso gonzalez Date: Tue, 5 Apr 2022 11:11:19 +0200 Subject: [PATCH 05/10] Update lib/messagebird/client.rb Co-authored-by: Jalerson Lima --- lib/messagebird/client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/messagebird/client.rb b/lib/messagebird/client.rb index 2b2bcee..75fe530 100644 --- a/lib/messagebird/client.rb +++ b/lib/messagebird/client.rb @@ -491,7 +491,7 @@ def add_contacts_query(contact_ids) # JSON by default. See also: # https://developers.messagebird.com/docs/alternatives. - '_method=PUT&' + contact_ids.map { |id| "ids[]=#{id}" }.join('&') # rubocop:disable Style/StringConcatenation + contact_ids.map { |id| "ids[]=#{id}" }.join('&').prepend('_method=PUT&') end def add_querystring(path, params) From 17248fda0f9e53ec4d770fe1360c177851569325 Mon Sep 17 00:00:00 2001 From: marcel corso gonzalez Date: Tue, 5 Apr 2022 11:11:39 +0200 Subject: [PATCH 06/10] Update spec/call_spec.rb Co-authored-by: Jalerson Lima --- spec/call_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/call_spec.rb b/spec/call_spec.rb index b6a83dc..98828a6 100644 --- a/spec/call_spec.rb +++ b/spec/call_spec.rb @@ -39,7 +39,7 @@ expect(voice_client) .to receive(:request) .with(:post, 'calls', { source: source, destination: destination, callFlow: call_flow.to_json }) - .and_return("{\"data\":[{\"id\":\"#{call_id}\",\"status\":\"queued\",\"source\":\"#{source}\",\"destination\":\"#{destination}\",\"createdAt\":\"2019-10-11T13:02:19Z\",\"updatedAt\":\"2019-10-11T13:02:19Z\",\"endedAt\":null}],\"_links\":{\"self\":\"/calls/#{call_id}\"},\"pagination\":{\"total_count\":0,\"pageCount\":0,\"currentPage\":0,\"perPage\":0}}") + .and_return("{'data':[{'id':'#{call_id}','status':'queued','source':'#{source}','destination':'#{destination}','createdAt':'2019-10-11T13:02:19Z','updatedAt':'2019-10-11T13:02:19Z','endedAt':null}],'_links':{'self':'/calls/#{call_id}'},'pagination':{'total_count':0,'pageCount':0,'currentPage':0,'perPage':0}}") call = client.call_create(source, destination, call_flow) expect(call.id).to eq call_id end From a53748434bf057e8d30615d40e96fdfeacb67bc7 Mon Sep 17 00:00:00 2001 From: marcel corso Date: Tue, 5 Apr 2022 11:19:55 +0200 Subject: [PATCH 07/10] fix again bad string. use heredoc --- spec/call_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/call_spec.rb b/spec/call_spec.rb index 98828a6..ed74d35 100644 --- a/spec/call_spec.rb +++ b/spec/call_spec.rb @@ -39,7 +39,7 @@ expect(voice_client) .to receive(:request) .with(:post, 'calls', { source: source, destination: destination, callFlow: call_flow.to_json }) - .and_return("{'data':[{'id':'#{call_id}','status':'queued','source':'#{source}','destination':'#{destination}','createdAt':'2019-10-11T13:02:19Z','updatedAt':'2019-10-11T13:02:19Z','endedAt':null}],'_links':{'self':'/calls/#{call_id}'},'pagination':{'total_count':0,'pageCount':0,'currentPage':0,'perPage':0}}") + .and_return(%Q({"data":[{"id":"#{call_id}","status":"queued","source":"#{source}","destination":"#{destination}","createdAt":"2019-10-11T13:02:19Z","updatedAt":"2019-10-11T13:02:19Z","endedAt":null}],"_links":{"self":"/calls/#{call_id}"},"pagination":{"total_count":0,"pageCount":0,"currentPage":0,"perPage":0}})) call = client.call_create(source, destination, call_flow) expect(call.id).to eq call_id end From eee307819a48a5ee5aed1c1c47a73c8bbdd6f9ff Mon Sep 17 00:00:00 2001 From: marcel corso Date: Tue, 5 Apr 2022 11:21:42 +0200 Subject: [PATCH 08/10] rubocop doesnt like %Q --- spec/call_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/call_spec.rb b/spec/call_spec.rb index ed74d35..248a36d 100644 --- a/spec/call_spec.rb +++ b/spec/call_spec.rb @@ -39,7 +39,7 @@ expect(voice_client) .to receive(:request) .with(:post, 'calls', { source: source, destination: destination, callFlow: call_flow.to_json }) - .and_return(%Q({"data":[{"id":"#{call_id}","status":"queued","source":"#{source}","destination":"#{destination}","createdAt":"2019-10-11T13:02:19Z","updatedAt":"2019-10-11T13:02:19Z","endedAt":null}],"_links":{"self":"/calls/#{call_id}"},"pagination":{"total_count":0,"pageCount":0,"currentPage":0,"perPage":0}})) + .and_return(%({"data":[{"id":"#{call_id}","status":"queued","source":"#{source}","destination":"#{destination}","createdAt":"2019-10-11T13:02:19Z","updatedAt":"2019-10-11T13:02:19Z","endedAt":null}],"_links":{"self":"/calls/#{call_id}"},"pagination":{"total_count":0,"pageCount":0,"currentPage":0,"perPage":0}})) call = client.call_create(source, destination, call_flow) expect(call.id).to eq call_id end From bea7298de8978554062d7cc952ca0056fd381854 Mon Sep 17 00:00:00 2001 From: marcel corso Date: Tue, 5 Apr 2022 13:09:34 +0200 Subject: [PATCH 09/10] add a test to try to catch a camelCase to underscore problem --- spec/call_flow_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/call_flow_spec.rb b/spec/call_flow_spec.rb index 0ee59e4..b8f28ee 100644 --- a/spec/call_flow_spec.rb +++ b/spec/call_flow_spec.rb @@ -89,17 +89,24 @@ createdAt: '2019-11-07T12:37:59Z', updatedAt: '2019-11-07T12:37:59Z' } - ] + ], + perPage: 2, + currentPage: 1, + totalCount: 111 } expect(voice_client) .to receive(:request) .with(:get, 'call-flows?perPage=2&page=1', {}) .and_return(mock_data.to_json) + list = client.call_flow_list(2, 1) expect(list.items.count).to eq 2 expect(list.items[0].id).to eq 'cfid-0000' + expect(list.per_page).to eq 2 + expect(list.current_page).to eq 1 + expect(list.total_count).to eq 111 end it 'view a call flow' do From d7523b65e849b6100068d20fff2a01a46098e41c Mon Sep 17 00:00:00 2001 From: marcel corso Date: Tue, 5 Apr 2022 13:11:07 +0200 Subject: [PATCH 10/10] thanks rubocop! you saved me <3 --- spec/call_flow_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/call_flow_spec.rb b/spec/call_flow_spec.rb index b8f28ee..6920fe1 100644 --- a/spec/call_flow_spec.rb +++ b/spec/call_flow_spec.rb @@ -105,7 +105,7 @@ expect(list.items.count).to eq 2 expect(list.items[0].id).to eq 'cfid-0000' expect(list.per_page).to eq 2 - expect(list.current_page).to eq 1 + expect(list.current_page).to eq 1 expect(list.total_count).to eq 111 end