mock-twilio 1.2.0 → 1.3.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: 310cc33586ef04e160217a0dfd84d974ac767e6f81d9af3f09d051f9fd802114
4
- data.tar.gz: e8e3391a767e0e5ba9270e4615df0dba90174b9715c8260c25c390155176829b
3
+ metadata.gz: 2a71b6dac5f7c25544671b2d8052b923e7bf84a16dc29f8d0243a06273562e28
4
+ data.tar.gz: 7620eaae9ab396ab492cc8fd0e2ec4df5e82d14d8caccc3fa1f47c7e1042b84b
5
5
  SHA512:
6
- metadata.gz: dcd5088423808878c3ba15bc7c2e36be36600ab2d4dc735d3f5d89ea9c37e29d0dc8a485b186ab01261bdcd3fb2d9f688f0f27ac9e9245930017883647cb41c2
7
- data.tar.gz: 428a6a44af8c26c0f3e06dd53863be5a68fd4efe94bc616f7bb3f712d8661853932a26171c15a69abff45174bee648800e25ce3d255f13e4d06cff8b3b0f978f
6
+ metadata.gz: c41c751585b29ce23a51baf02df01b3f8b3ddb911c2570ea65df66a83d040c192d1867e124502eb0c53ca5ed7a96b479c79de82a1dbffcda472bc48418edc2e7
7
+ data.tar.gz: 2e40c25d80bae526531613a86661ff9cf00cab5ef3ff9208df3ef4748d21639dc5c83fafb5f96c8065cd16c7857a11ae88515238e3bdde3dfae2a6eee8c65a9b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [1.3.0] - 2024-10-10
2
+ - Support IncomingPhoneNumbers Updates
3
+ - Support CustomerProfilesV1 ChannelEndpointAssignments
4
+ - Support TrustProductsV1 ChannelEndpointAssignments
5
+ - Unlock gemspec dependencies
6
+
1
7
  ## [1.2.0] - 2024-09-30
2
8
  - Add direct calls voicemail support
3
9
 
data/README.md CHANGED
@@ -34,11 +34,16 @@ OR
34
34
  | :white_check_mark: | `client.messaging.v1.services("MG"+"F"*32).phone_numbers.create(phone_number_sid: @phone_number_sid)` |
35
35
  | :white_check_mark: | `client.available_phone_numbers('US').local.list(limit: 20)` |
36
36
  | :white_check_mark: | `client.incoming_phone_numbers.create(phone_number: "+1987654321", voice_url: "#{BASE_URL}/api/v1/twilio_calls/incoming", sms_url: "#{BASE_URL}/api/v1/twilio_requests/inbound")` |
37
+ | :white_check_mark: | `client.incoming_phone_numbers.update(sms_application_sid: "AP"+"F"*32, voice_application_sid: "AP"+"F"*32)` |
37
38
  | :white_check_mark: | `client.lookups.v2.phone_numbers("+14159929960").fetch(fields: :line_type_intelligence)` |
38
39
  | :white_check_mark: | `client.calls.create(url: '<http://demo.twilio.com/docs/voice.xml>', to: '+14155551212', from: '+15017122661', status_callback: '<https://myapp.com/events>', status_callback_event: ['ringing'], status_callback_method: 'POST')` |
39
40
  | :white_check_mark: | `client.conferences("CF"+("F")*32).participants.create(label: 'customer', early_media: true, beep: 'onEnter', status_callback: '<https://myapp.com/events>', status_callback_event: ['ringing'], record: true, from: '+15017122661', to: '+15558675310')` |
40
41
  | :white_check_mark: | `client.trusthub.v1.customer_profiles.create(**twilio_attributes)` |
41
42
  | :white_check_mark: | `client.trusthub.v1.customer_profiles(customer_profile_sid).customer_profiles_entity_assignments.create(object_sid:)` |
43
+ | :white_check_mark: | `client.trusthub.v1.customer_profiles("BU"+"F"*32).customer_profiles_channel_endpoint_assignment.list(limit: 20)` |
44
+ | :white_check_mark: | `client.trusthub.v1.customer_profiles("BU"+"F"*32).customer_profiles_channel_endpoint_assignment("RA"+"F"*32).delete` |
45
+ | :white_check_mark: | `client.trusthub.v1.trust_products("BU"+"F"*32).trust_products_channel_endpoint_assignment.list(limit: 20)` |
46
+ | :white_check_mark: | `client.trusthub.v1.trust_products("BU"+"F"*32).trust_products_channel_endpoint_assignment("RA"+"F"*32).delete` |
42
47
  | :white_check_mark: | `client.trusthub.v1.end_users.create(**twilio_parameters)`
43
48
  | :white_check_mark: | `client.trusthub.v1.supporting_documents.create(**twilio_parameters)` |
44
49
  | :white_check_mark: | `client.addresses.create(**twilio_parameters)` |
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mock
4
+ module Twilio
5
+ module Decorators
6
+ module Api2010
7
+ class IncomingPhoneNumbers
8
+ class << self
9
+ include Mock::Twilio::Generator
10
+
11
+ def decorate(body, request)
12
+ body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
13
+ body["date_created"] = Time.current.rfc2822 if body["date_created"]
14
+ body["account_sid"] = ::Twilio.account_sid if body["account_sid"]
15
+
16
+ body["sid"] = random_phone_number_sid if body["sid"]
17
+ body["identity_sid"] = random_identity_sid if body["identity_sid"]
18
+ body["emergency_address_sid"] = random_address_sid if body["emergency_address_sid"]
19
+ body["address_sid"] = random_address_sid if body["address_sid"]
20
+ body["bundle_sid"] = random_bundle_sid if body["bundle_sid"]
21
+
22
+ body
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mock
4
+ module Twilio
5
+ module Decorators
6
+ module CustomerProfilesV1
7
+ class ChannelEndpointAssignments
8
+ class << self
9
+ include Mock::Twilio::Generator
10
+
11
+ def decorate(body, request)
12
+ decorate_results(body, request) unless body["results"].nil?
13
+ decorate_meta(body, request) unless body["meta"].nil?
14
+
15
+ body
16
+ end
17
+
18
+ private
19
+
20
+ def decorate_meta(body, request)
21
+ customer_profile_sid = parse_customer_profile_sid(request)
22
+
23
+ body["meta"].tap do |meta|
24
+ page_size = body["results"].length
25
+ meta["page_size"] = page_size
26
+ meta["first_page_url"] = "https://trusthub.twilio.com/v1/CustomerProfiles#{customer_profile_sid}/ChannelEndpointAssignments?PageSize=#{page_size}&Page=0"
27
+ meta["previous_page_url"] = nil
28
+ meta["next_page_url"] = nil
29
+ meta["url"] = "https://trusthub.twilio.com/v1/CustomerProfiles#{customer_profile_sid}/ChannelEndpointAssignments?PageSize=#{page_size}&Page=0"
30
+ meta["key"] = "results"
31
+ end
32
+ end
33
+
34
+ def decorate_results(body, request)
35
+ customer_profile_sid = parse_customer_profile_sid(request)
36
+
37
+ body["results"].each do |result|
38
+ result["customer_profile_sid"] = customer_profile_sid if result["customer_profile_sid"]
39
+ result["sid"] = random_assignment_sid if result["sid"]
40
+ result["channel_endpoint_sid"] = random_phone_number_sid if result["channel_endpoint_sid"]
41
+ result["url"] = "https://trusthub.twilio.com/v1/CustomerProfiles/#{customer_profile_sid}/ChannelEndpointAssignments/#{result["sid"]}"
42
+ result["channel_endpoint_type"] = "phone-number" if result["channel_endpoint_type"]
43
+ result["account_sid"] = ::Twilio.account_sid
44
+ result["date_created"] = Time.current.rfc2822 if result["date_created"]
45
+ end
46
+ end
47
+
48
+ def parse_customer_profile_sid(request)
49
+ uri = URI(request.url)
50
+ uri.path.split('/')[3]
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mock
4
+ module Twilio
5
+ module Decorators
6
+ module TrustProductsV1
7
+ class ChannelEndpointAssignments
8
+ class << self
9
+ include Mock::Twilio::Generator
10
+
11
+ def decorate(body, request)
12
+ decorate_results(body, request) unless body["results"].nil?
13
+ decorate_meta(body, request) unless body["meta"].nil?
14
+
15
+ body
16
+ end
17
+
18
+ private
19
+
20
+ def decorate_meta(body, request)
21
+ trust_product_sid = parse_trust_product_sid(request)
22
+
23
+ body["meta"].tap do |meta|
24
+ page_size = body["results"].length
25
+ meta["page_size"] = page_size
26
+ meta["first_page_url"] = "https://trusthub.twilio.com/v1/TrustProducts/#{trust_product_sid}/ChannelEndpointAssignments?PageSize=#{page_size}&Page=0"
27
+ meta["previous_page_url"] = nil
28
+ meta["next_page_url"] = nil
29
+ meta["url"] = "https://trusthub.twilio.com/v1/TrustProducts/#{trust_product_sid}/ChannelEndpointAssignments?PageSize=#{page_size}&Page=0"
30
+ meta["key"] = "results"
31
+ end
32
+ end
33
+
34
+ def decorate_results(body, request)
35
+ trust_product_sid = parse_trust_product_sid(request)
36
+
37
+ body["results"].each do |result|
38
+ result["trust_product_sid"] = trust_product_sid if result["trust_product_sid"]
39
+ result["sid"] = random_assignment_sid if result["sid"]
40
+ result["channel_endpoint_sid"] = random_phone_number_sid if result["channel_endpoint_sid"]
41
+ result["url"] = "https://trusthub.twilio.com/v1/TrustProducts/#{trust_product_sid}/ChannelEndpointAssignments/#{result["sid"]}"
42
+ result["channel_endpoint_type"] = "phone-number" if result["channel_endpoint_type"]
43
+ result["account_sid"] = ::Twilio.account_sid
44
+ result["date_created"] = Time.current.rfc2822 if result["date_created"]
45
+ end
46
+ end
47
+
48
+ def parse_trust_product_sid(request)
49
+ uri = URI(request.url)
50
+ uri.path.split('/')[3]
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -5,6 +5,7 @@ require_relative "../decorators/api_2010/calls"
5
5
  require_relative "../decorators/api_2010/conferences_participants_update"
6
6
  require_relative "../decorators/api_2010/conferences_participants_create"
7
7
  require_relative "../decorators/api_2010/addresses"
8
+ require_relative "../decorators/api_2010/incoming_phone_numbers"
8
9
 
9
10
  module Mock
10
11
  module Twilio
@@ -17,6 +18,7 @@ module Mock
17
18
  conferences_participants_update: Mock::Twilio::Decorators::Api2010::ConferencesParticipantsUpdate,
18
19
  conferences_participants_create: Mock::Twilio::Decorators::Api2010::ConferencesParticipantsCreate,
19
20
  addresses: Mock::Twilio::Decorators::Api2010::Addresses,
21
+ incoming_phone_numbers: Mock::Twilio::Decorators::Api2010::IncomingPhoneNumbers,
20
22
  }
21
23
 
22
24
  PAGES_KEYS = [
@@ -47,6 +49,8 @@ module Mock
47
49
  RESOURCES[:conferences_participants_create].decorate(body, request)
48
50
  when %r{\/2010-04-01/Accounts/[A-Za-z0-9]+/Addresses.json}
49
51
  RESOURCES[:addresses].decorate(body, request)
52
+ when %r{\/2010-04-01/Accounts/[A-Za-z0-9]+/IncomingPhoneNumbers/[A-Za-z0-9]+.json}
53
+ RESOURCES[:incoming_phone_numbers].decorate(body, request)
50
54
  end
51
55
  end
52
56
  end
@@ -4,6 +4,7 @@ require_relative "../decorators/customer_profiles_v1/customer_profile"
4
4
  require_relative "../decorators/customer_profiles_v1/entity_assignments"
5
5
  require_relative "../decorators/customer_profiles_v1/evaluations"
6
6
  require_relative "../decorators/customer_profiles_v1/customer_profile_update"
7
+ require_relative "../decorators/customer_profiles_v1/channel_endpoint_assignments"
7
8
 
8
9
  module Mock
9
10
  module Twilio
@@ -15,19 +16,26 @@ module Mock
15
16
  entity_assigments: Mock::Twilio::Decorators::CustomerProfilesV1::EntityAssignments,
16
17
  evaluations: Mock::Twilio::Decorators::CustomerProfilesV1::Evaluations,
17
18
  customer_profile_update: Mock::Twilio::Decorators::CustomerProfilesV1::CustomerProfileUpdate,
19
+ channel_endpoint_assignments: Mock::Twilio::Decorators::CustomerProfilesV1::ChannelEndpointAssignments,
18
20
  }
19
21
 
20
22
  def for(body, request)
21
23
  url = request.url.split(request.host).last
22
24
 
23
25
  case url
24
- when %r{\/v1/CustomerProfiles$}
26
+ when %r{/v1/CustomerProfiles$}
25
27
  RESOURCES[:customer_profile].decorate(body, request)
26
- when %r{\/v1/CustomerProfiles/[A-Za-z0-9]+/EntityAssignments}
28
+ when %r{/v1/CustomerProfiles/[A-Za-z0-9]+/EntityAssignments}
27
29
  RESOURCES[:entity_assigments].decorate(body, request)
28
- when %r{\/v1/CustomerProfiles/[A-Za-z0-9]+/Evaluations}
30
+ when %r{/v1/CustomerProfiles/[A-Za-z0-9]+/Evaluations}
29
31
  RESOURCES[:evaluations].decorate(body, request)
30
- when %r{\/v1/CustomerProfiles/[A-Za-z0-0]+}
32
+ when %r{/v1/CustomerProfiles/[A-Za-z0-9]+/ChannelEndpointAssignments}
33
+ if request.method.downcase == 'get'
34
+ RESOURCES[:channel_endpoint_assignments].decorate(body, request)
35
+ else
36
+ body
37
+ end
38
+ when %r{/v1/CustomerProfiles/[A-Za-z0-0]+}
31
39
  RESOURCES[:customer_profile_update].decorate(body, request)
32
40
  end
33
41
  end
@@ -4,6 +4,7 @@ require_relative "../decorators/trust_products_v1/trust_products"
4
4
  require_relative "../decorators/trust_products_v1/update"
5
5
  require_relative "../decorators/trust_products_v1/evaluations"
6
6
  require_relative "../decorators/trust_products_v1/entity_assignments"
7
+ require_relative "../decorators/trust_products_v1/channel_endpoint_assignments"
7
8
 
8
9
  module Mock
9
10
  module Twilio
@@ -15,20 +16,27 @@ module Mock
15
16
  update: Mock::Twilio::Decorators::TrustProductsV1::Update,
16
17
  evaluations: Mock::Twilio::Decorators::TrustProductsV1::Evaluations,
17
18
  entity_assignments: Mock::Twilio::Decorators::TrustProductsV1::EntityAssignments,
19
+ channel_endpoint_assignments: Mock::Twilio::Decorators::TrustProductsV1::ChannelEndpointAssignments,
18
20
  }
19
21
 
20
22
  def for(body, request)
21
23
  url = request.url.split(request.host).last
22
24
 
23
25
  case url
24
- when %r{\/v1/TrustProducts$}
26
+ when %r{/v1/TrustProducts$}
25
27
  RESOURCES[:trust_products].decorate(body, request)
26
- when %r{\/v1/TrustProducts/\w{34}$}
28
+ when %r{/v1/TrustProducts/\w{34}$}
27
29
  RESOURCES[:update].decorate(body, request)
28
- when %r{\/v1\/TrustProducts\/\w{34}\/Evaluations$}
30
+ when %r{/v1/TrustProducts/\w{34}/Evaluations$}
29
31
  RESOURCES[:evaluations].decorate(body, request)
30
- when %r{\/v1\/TrustProducts\/\w{34}\/EntityAssignments$}
32
+ when %r{/v1/TrustProducts/\w{34}/EntityAssignments$}
31
33
  RESOURCES[:entity_assignments].decorate(body, request)
34
+ when %r{/v1/TrustProducts/[A-Za-z0-9]+/ChannelEndpointAssignments}
35
+ if request.method.downcase == 'get'
36
+ RESOURCES[:channel_endpoint_assignments].decorate(body, request)
37
+ else
38
+ body
39
+ end
32
40
  end
33
41
  end
34
42
  end
@@ -6,6 +6,40 @@ module Mock
6
6
  def phone_number_generator
7
7
  "+1" + rand(100000000..999999999).to_s
8
8
  end
9
+
10
+ def random_phone_number_sid
11
+ random_sid_prefixed_by "PN"
12
+ end
13
+
14
+ def random_account_sid
15
+ random_sid_prefixed_by "AC"
16
+ end
17
+
18
+ def random_twiml_app_sid
19
+ random_sid_prefixed_by "AP"
20
+ end
21
+
22
+ def random_identity_sid
23
+ random_sid_prefixed_by "RI"
24
+ end
25
+
26
+ def random_address_sid
27
+ random_sid_prefixed_by "AD"
28
+ end
29
+
30
+ def random_bundle_sid
31
+ random_sid_prefixed_by "BU"
32
+ end
33
+
34
+ def random_assignment_sid
35
+ random_sid_prefixed_by "RA"
36
+ end
37
+
38
+ private
39
+
40
+ def random_sid_prefixed_by(prefix)
41
+ "#{prefix}#{SecureRandom.hex(16)}"
42
+ end
9
43
  end
10
44
  end
11
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mock
4
4
  module Twilio
5
- VERSION = "1.2.0"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock-twilio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SchoolStatus Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-30 00:00:00.000000000 Z
11
+ date: 2024-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.9.1
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
26
  version: 2.9.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rufus-scheduler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.9.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.9.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: twilio-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 7.1.0
47
+ version: 7.0.0
48
48
  type: :runtime
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: 7.1.0
54
+ version: 7.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 7.1.3.4
61
+ version: 6.0.0
62
62
  type: :runtime
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: 7.1.3.4
68
+ version: 6.0.0
69
69
  description: This repository contains Mock::Twilio::Client for Twilio's API.
70
70
  email:
71
71
  executables: []
@@ -84,7 +84,9 @@ files:
84
84
  - lib/mock/twilio/decorators/api_2010/calls.rb
85
85
  - lib/mock/twilio/decorators/api_2010/conferences_participants_create.rb
86
86
  - lib/mock/twilio/decorators/api_2010/conferences_participants_update.rb
87
+ - lib/mock/twilio/decorators/api_2010/incoming_phone_numbers.rb
87
88
  - lib/mock/twilio/decorators/api_2010/messages.rb
89
+ - lib/mock/twilio/decorators/customer_profiles_v1/channel_endpoint_assignments.rb
88
90
  - lib/mock/twilio/decorators/customer_profiles_v1/customer_profile.rb
89
91
  - lib/mock/twilio/decorators/customer_profiles_v1/customer_profile_update.rb
90
92
  - lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
@@ -92,6 +94,7 @@ files:
92
94
  - lib/mock/twilio/decorators/messaging_v1/phone_number_create.rb
93
95
  - lib/mock/twilio/decorators/messaging_v1/phone_number_fetch.rb
94
96
  - lib/mock/twilio/decorators/messaging_v1/phone_number_list.rb
97
+ - lib/mock/twilio/decorators/trust_products_v1/channel_endpoint_assignments.rb
95
98
  - lib/mock/twilio/decorators/trust_products_v1/entity_assignments.rb
96
99
  - lib/mock/twilio/decorators/trust_products_v1/evaluations.rb
97
100
  - lib/mock/twilio/decorators/trust_products_v1/trust_products.rb
@@ -144,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
147
  - !ruby/object:Gem::Version
145
148
  version: '0'
146
149
  requirements: []
147
- rubygems_version: 3.4.19
150
+ rubygems_version: 3.5.12
148
151
  signing_key:
149
152
  specification_version: 4
150
153
  summary: This repository contains Mock::Twilio::Client and Webhooks for Twilio's API.