telnyx 3.0.5 → 3.0.6

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: 1c54ee2fae1e5040ea3a33bab7b8d103e0727f9a4bfd966d3ce33bd8c5fef194
4
- data.tar.gz: f9c16f95c3bf511e70002362b18caf01f4455bbfcb79252946b665f968b1131d
3
+ metadata.gz: 119256278a1a98976546bc78f69fbc4f14f08deb8dea0f492833e1e7fc90d5f8
4
+ data.tar.gz: 64c553ce027e5e14e79d93f635b32d5032aacfcf16c951dc6b8c6dc24f1a3a1c
5
5
  SHA512:
6
- metadata.gz: 19b78fe8dab94fc40f4ed470339e612dccd1db21b059d5ee58620f57f3d02035d1aece4778d9c0179cb9f212908c62e8bddbe26894dae231dd823293b22ba2a3
7
- data.tar.gz: 8065a019140e93780bd21c69b3479b02ebd2b90ddf1b29945e2053c768e811e12d11aa9e94f28de3ffd5f42d3a4bec576b6f8aa5b39bb132c5860cacffc901d1
6
+ metadata.gz: 789ca83329b14511166e268d8a1549cd4aefb92d297b134df98761ef0b38fcb1877c9727777c827f84a896e1a37138799b647b2d7dcdc3bef951bc6551c207d0
7
+ data.tar.gz: 9d71107f074a2bd0c8e33f9d1645545a0334931fce33e436bc5e06dc90bdda7bb6c8ec6364eb82f9f0a8de8203a7bee86e201b8b137f4eafbfcd8890e2146795
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.5
1
+ 3.0.6
@@ -13,10 +13,13 @@ module Telnyx
13
13
 
14
14
  def wrap(method_name, wrapper)
15
15
  define_singleton_method(method_name) do |filters = {}, opts = {}|
16
- return super(filters, opts) if filters.keys == [wrapper]
17
-
18
- filters = { wrapper => filters }
19
- super filters, opts
16
+ # If the only key is the wrapper key (e.g., 'filter'), pass it through as is
17
+ if filters.keys == [wrapper.to_sym] || filters.keys == [wrapper.to_s]
18
+ super(filters, opts)
19
+ else
20
+ # Otherwise, wrap the parameters in the wrapper key
21
+ super({ wrapper => filters }, opts)
22
+ end
20
23
  end
21
24
  end
22
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telnyx
4
- VERSION = "3.0.5".freeze
4
+ VERSION = "3.0.6".freeze
5
5
  end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../test_helper"
4
+
5
+ module Telnyx
6
+ class ParamWrapperTest < Test::Unit::TestCase
7
+ class TestResource < APIResource
8
+ extend Telnyx::APIOperations::List
9
+ extend Telnyx::APIOperations::ParamWrapper
10
+ wrap "list", "filter"
11
+
12
+ OBJECT_NAME = "test_resource"
13
+
14
+ # Override request to avoid actual API calls
15
+ def self.request(method, url, params = {}, opts = {})
16
+ # Store the parameters for verification
17
+ @@last_request_params = params
18
+
19
+ # Return a mock response
20
+ resp = Struct.new(:data).new({ data: [] })
21
+ [resp, {}]
22
+ end
23
+
24
+ # Method to retrieve the last request parameters
25
+ def self.last_request_params
26
+ @@last_request_params
27
+ end
28
+ end
29
+
30
+ context ".list" do
31
+ should "correctly handle parameters when filter is explicitly provided" do
32
+ params = {
33
+ filter: {
34
+ country_code: "US",
35
+ limit: 1,
36
+ phone_number: { starts_with: "123" }
37
+ }
38
+ }
39
+
40
+ TestResource.list(params)
41
+
42
+ # Verify the parameters were passed correctly - note that keys may be strings or symbols
43
+ params = TestResource.last_request_params
44
+
45
+ # Convert all keys to symbols for consistent comparison
46
+ params_with_symbol_keys = {}
47
+ params.each do |k, v|
48
+ params_with_symbol_keys[k.to_sym] = v
49
+ end
50
+
51
+ assert_equal(
52
+ { filter: { country_code: "US", limit: 1, phone_number: { starts_with: "123" } } },
53
+ params_with_symbol_keys
54
+ )
55
+ end
56
+
57
+ should "correctly wrap parameters when filter is not explicitly provided" do
58
+ params = {
59
+ country_code: "US",
60
+ limit: 1,
61
+ phone_number: { starts_with: "123" }
62
+ }
63
+
64
+ TestResource.list(params)
65
+
66
+ # Verify the parameters were wrapped correctly - note that keys may be strings or symbols
67
+ params = TestResource.last_request_params
68
+
69
+ # Convert all keys to symbols for consistent comparison
70
+ params_with_symbol_keys = {}
71
+ params.each do |k, v|
72
+ params_with_symbol_keys[k.to_sym] = v
73
+ end
74
+
75
+ assert_equal(
76
+ { filter: { country_code: "US", limit: 1, phone_number: { starts_with: "123" } } },
77
+ params_with_symbol_keys
78
+ )
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,51 @@
1
+ require 'bundler/setup'
2
+ require 'telnyx'
3
+
4
+ # Set a dummy API key
5
+ Telnyx.api_key = 'TEST_API_KEY'
6
+
7
+ # Monkey patch the request method to capture parameters without making API calls
8
+ module Telnyx
9
+ module APIOperations
10
+ module Request
11
+ module ClassMethods
12
+ alias original_request request
13
+
14
+ def request(method, url, params = {}, opts = {})
15
+ puts "Method: #{method}"
16
+ puts "URL: #{url}"
17
+ puts "Raw params: #{params.inspect}"
18
+
19
+ if method.to_s.downcase.to_sym == :get
20
+ puts "URL-encoded params: #{Telnyx::Util.encode_parameters(params)}"
21
+ else
22
+ puts "JSON body: #{JSON.generate(params)}"
23
+ end
24
+
25
+ # Return a mock response
26
+ mock_response = Struct.new(:data).new({data: []})
27
+ [mock_response, {}]
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ # Test with the parameters from the example
35
+ puts "\n=== Testing with filter hash ==="
36
+ response = Telnyx::AvailablePhoneNumber.list(
37
+ filter: {
38
+ country_code: "US",
39
+ limit: 1,
40
+ national_destination_code: "206",
41
+ phone_number: { starts_with: "4532888" }
42
+ }
43
+ )
44
+
45
+ puts "\n=== Testing with direct parameters ==="
46
+ response = Telnyx::AvailablePhoneNumber.list(
47
+ country_code: "US",
48
+ limit: 1,
49
+ national_destination_code: "206",
50
+ phone_number: { starts_with: "4532888" }
51
+ )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telnyx
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Telnyx
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-18 00:00:00.000000000 Z
11
+ date: 2025-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -326,6 +326,7 @@ files:
326
326
  - test/telnyx/number_reservation_test.rb
327
327
  - test/telnyx/ota_update_test.rb
328
328
  - test/telnyx/outbound_voice_profile_test.rb
329
+ - test/telnyx/param_wrapper_test.rb
329
330
  - test/telnyx/phone_number_block_job_test.rb
330
331
  - test/telnyx/phone_number_regulatory_requirement_test.rb
331
332
  - test/telnyx/phone_number_test.rb
@@ -370,6 +371,7 @@ files:
370
371
  - test/telnyx_test.rb
371
372
  - test/test_data.rb
372
373
  - test/test_helper.rb
374
+ - test/test_params.rb
373
375
  homepage: https://developers.telnyx.com
374
376
  licenses:
375
377
  - MIT
@@ -378,7 +380,7 @@ metadata:
378
380
  github_repo: ssh://github.com/team-telnyx/telnyx-ruby
379
381
  homepage_uri: https://telnyx.com
380
382
  source_code_uri: https://github.com/team-telnyx/telnyx-ruby
381
- post_install_message:
383
+ post_install_message:
382
384
  rdoc_options: []
383
385
  require_paths:
384
386
  - lib
@@ -394,7 +396,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
394
396
  version: '0'
395
397
  requirements: []
396
398
  rubygems_version: 3.2.15
397
- signing_key:
399
+ signing_key:
398
400
  specification_version: 4
399
401
  summary: Ruby bindings for the Telnyx API
400
402
  test_files:
@@ -465,6 +467,7 @@ test_files:
465
467
  - test/telnyx/number_reservation_test.rb
466
468
  - test/telnyx/ota_update_test.rb
467
469
  - test/telnyx/outbound_voice_profile_test.rb
470
+ - test/telnyx/param_wrapper_test.rb
468
471
  - test/telnyx/phone_number_block_job_test.rb
469
472
  - test/telnyx/phone_number_regulatory_requirement_test.rb
470
473
  - test/telnyx/phone_number_test.rb
@@ -509,3 +512,4 @@ test_files:
509
512
  - test/telnyx_test.rb
510
513
  - test/test_data.rb
511
514
  - test/test_helper.rb
515
+ - test/test_params.rb