surge_api 0.8.0 → 0.9.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +29 -1
  4. data/lib/surge_api/internal/cursor.rb +112 -0
  5. data/lib/surge_api/internal/transport/pooled_net_requester.rb +1 -1
  6. data/lib/surge_api/models/blast.rb +2 -2
  7. data/lib/surge_api/models/blast_create_params.rb +4 -4
  8. data/lib/surge_api/models/contact_list_params.rb +34 -0
  9. data/lib/surge_api/models/message.rb +2 -2
  10. data/lib/surge_api/models/message_delivered_webhook_event.rb +3 -3
  11. data/lib/surge_api/models/message_failed_webhook_event.rb +3 -3
  12. data/lib/surge_api/models/message_list_params.rb +34 -0
  13. data/lib/surge_api/models/message_received_webhook_event.rb +3 -3
  14. data/lib/surge_api/models/message_sent_webhook_event.rb +3 -3
  15. data/lib/surge_api/models/phone_number.rb +1 -1
  16. data/lib/surge_api/models/phone_number_list_params.rb +34 -0
  17. data/lib/surge_api/models.rb +6 -0
  18. data/lib/surge_api/resources/blasts.rb +1 -1
  19. data/lib/surge_api/resources/contacts.rb +30 -0
  20. data/lib/surge_api/resources/messages.rb +30 -0
  21. data/lib/surge_api/resources/phone_numbers.rb +30 -0
  22. data/lib/surge_api/version.rb +1 -1
  23. data/lib/surge_api.rb +4 -0
  24. data/rbi/surge_api/internal/cursor.rbi +52 -0
  25. data/rbi/surge_api/models/blast.rbi +3 -6
  26. data/rbi/surge_api/models/blast_create_params.rbi +3 -6
  27. data/rbi/surge_api/models/contact_list_params.rbi +59 -0
  28. data/rbi/surge_api/models/message.rbi +3 -6
  29. data/rbi/surge_api/models/message_delivered_webhook_event.rbi +3 -3
  30. data/rbi/surge_api/models/message_failed_webhook_event.rbi +3 -3
  31. data/rbi/surge_api/models/message_list_params.rbi +59 -0
  32. data/rbi/surge_api/models/message_received_webhook_event.rbi +3 -3
  33. data/rbi/surge_api/models/message_sent_webhook_event.rbi +3 -3
  34. data/rbi/surge_api/models/phone_number_list_params.rbi +59 -0
  35. data/rbi/surge_api/models.rbi +6 -0
  36. data/rbi/surge_api/resources/blasts.rbi +1 -1
  37. data/rbi/surge_api/resources/contacts.rbi +21 -0
  38. data/rbi/surge_api/resources/messages.rbi +21 -0
  39. data/rbi/surge_api/resources/phone_numbers.rbi +21 -0
  40. data/sig/surge_api/internal/cursor.rbs +28 -0
  41. data/sig/surge_api/models/blast.rbs +4 -6
  42. data/sig/surge_api/models/blast_create_params.rbs +4 -6
  43. data/sig/surge_api/models/contact_list_params.rbs +32 -0
  44. data/sig/surge_api/models/message.rbs +4 -6
  45. data/sig/surge_api/models/message_delivered_webhook_event.rbs +4 -4
  46. data/sig/surge_api/models/message_failed_webhook_event.rbs +4 -4
  47. data/sig/surge_api/models/message_list_params.rbs +32 -0
  48. data/sig/surge_api/models/message_received_webhook_event.rbs +4 -4
  49. data/sig/surge_api/models/message_sent_webhook_event.rbs +4 -4
  50. data/sig/surge_api/models/phone_number_list_params.rbs +32 -0
  51. data/sig/surge_api/models.rbs +6 -0
  52. data/sig/surge_api/resources/blasts.rbs +1 -1
  53. data/sig/surge_api/resources/contacts.rbs +7 -0
  54. data/sig/surge_api/resources/messages.rbs +7 -0
  55. data/sig/surge_api/resources/phone_numbers.rbs +7 -0
  56. metadata +14 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d974f7f96df8e8e8452c8693d8afe99108691e4765da89ed06670ad635f3a48
4
- data.tar.gz: 4f7eedf44e0f6c2b0d076f2c590d07519c666ae2d20fc12a5b0cef4fa2b451dd
3
+ metadata.gz: c8cabbc1ca93255610f86e41e4408ee35552d4755552e0bb63dec43d34e37847
4
+ data.tar.gz: 94fd6a84dd1d08f71b3fb51125010f75d03f824538078a70103213297391c30b
5
5
  SHA512:
6
- metadata.gz: 4b03295d43f70c73f3db451516682c5ff8e5e7c081db91e7ed98628500f3f7cb637952dc60631f76e6d83dbf8a571ca1c90e4fb0dc3ce00ae0b759ca1ed8bfeb
7
- data.tar.gz: 44ec0232e66a93b385447ccc5cd6ee433d7f3e944e96b69c2cf7badde81fdf46b630b9501a386067bffc10896de0eb864c2720814fe4e295fcc1a924fd8f2205
6
+ metadata.gz: cce465d2b1f99e690347727f8e987b6afa07a0cd2eadfb0e0832b1bf1100477ae03592e774c9ee8929d9c2eb5903e820fac12ca0d8d28a6ed1207dcdabc33a3c
7
+ data.tar.gz: 184ca9625b88a0b8366f92f0760e1fd5f53abd52752a4c0284b99429442cc69280b29e9758d94381a0ca4fba98e693f36d083710a17883ad13c4aaae3b83d39b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0 (2026-02-04)
4
+
5
+ Full Changelog: [v0.8.0...v0.9.0](https://github.com/surgeapi/ruby-sdk/compare/v0.8.0...v0.9.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** add list contacts endpoint ([fb3eaae](https://github.com/surgeapi/ruby-sdk/commit/fb3eaae32fa15b6b7423b4ae485608e03cf027a7))
10
+ * **api:** add list messages endpoint ([ca51f12](https://github.com/surgeapi/ruby-sdk/commit/ca51f12d83bcebdd706701e8fee9a594313bd767))
11
+ * **api:** add list phone numbers endpoint ([47691df](https://github.com/surgeapi/ruby-sdk/commit/47691dfe6f91a9300c02f3f893fe2af5636f8094))
12
+ * **sdk:** add deprecation messages ([f0e959e](https://github.com/surgeapi/ruby-sdk/commit/f0e959e9a96069670284b7ebd9f9a0a28672b5dc))
13
+ * **sdks:** set up pagination ([08b1393](https://github.com/surgeapi/ruby-sdk/commit/08b13930dd2102f1886c616409f213e62b3137e5))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **api:** make message body nullable ([a329e52](https://github.com/surgeapi/ruby-sdk/commit/a329e5203323524beb725f217d0261193df02ebe))
19
+ * **client:** always add content-length to post body, even when empty ([12467d3](https://github.com/surgeapi/ruby-sdk/commit/12467d365020dafafb0474504042a8e39c5ee2fd))
20
+
21
+
22
+ ### Chores
23
+
24
+ * **docs:** remove www prefix ([beaff0c](https://github.com/surgeapi/ruby-sdk/commit/beaff0c151d0e31114c490c09fb4c71196e316d8))
25
+
3
26
  ## 0.8.0 (2026-01-26)
4
27
 
5
28
  Full Changelog: [v0.7.0...v0.8.0](https://github.com/surgeapi/ruby-sdk/compare/v0.7.0...v0.8.0)
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "surge_api", "~> 0.8.0"
20
+ gem "surge_api", "~> 0.9.0"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -37,6 +37,34 @@ message = surge.messages.create("acct_01j9a43avnfqzbjfch6pygv1td")
37
37
  puts(message.id)
38
38
  ```
39
39
 
40
+ ### Pagination
41
+
42
+ List methods in the Surge API are paginated.
43
+
44
+ This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
45
+
46
+ ```ruby
47
+ page = surge.contacts.list
48
+
49
+ # Fetch single item from page.
50
+ contact = page.data[0]
51
+ puts(contact.id)
52
+
53
+ # Automatically fetches more pages as needed.
54
+ page.auto_paging_each do |contact|
55
+ puts(contact.id)
56
+ end
57
+ ```
58
+
59
+ Alternatively, you can use the `#next_page?` and `#next_page` methods for more granular control working with pages.
60
+
61
+ ```ruby
62
+ if page.next_page?
63
+ new_page = page.next_page
64
+ puts(new_page.data[0].id)
65
+ end
66
+ ```
67
+
40
68
  ### Handling errors
41
69
 
42
70
  When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `SurgeAPI::Errors::APIError` will be thrown:
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Internal
5
+ # @generic Elem
6
+ #
7
+ # @example
8
+ # if cursor.has_next?
9
+ # cursor = cursor.next_page
10
+ # end
11
+ #
12
+ # @example
13
+ # cursor.auto_paging_each do |contact|
14
+ # puts(contact)
15
+ # end
16
+ class Cursor
17
+ include SurgeAPI::Internal::Type::BasePage
18
+
19
+ # @return [Array<generic<Elem>>, nil]
20
+ attr_accessor :data
21
+
22
+ # @return [Pagination]
23
+ attr_accessor :pagination
24
+
25
+ # @return [Boolean]
26
+ def next_page?
27
+ !data.to_a.empty? && (!pagination&.previous_cursor.to_s.empty? || !pagination&.next_cursor.to_s.empty?)
28
+ end
29
+
30
+ # @raise [SurgeAPI::HTTP::Error]
31
+ # @return [self]
32
+ def next_page
33
+ unless next_page?
34
+ message = "No more pages available. Please check #next_page? before calling ##{__method__}"
35
+ raise RuntimeError.new(message)
36
+ end
37
+
38
+ req = SurgeAPI::Internal::Util.deep_merge(
39
+ @req,
40
+ {
41
+ query: pagination&.previous_cursor.nil? ? {after: pagination&.next_cursor} : {before: pagination&.previous_cursor}
42
+ }
43
+ )
44
+ @client.request(req)
45
+ end
46
+
47
+ # @param blk [Proc]
48
+ #
49
+ # @yieldparam [generic<Elem>]
50
+ def auto_paging_each(&blk)
51
+ unless block_given?
52
+ raise ArgumentError.new("A block must be given to ##{__method__}")
53
+ end
54
+
55
+ page = self
56
+ loop do
57
+ page.data&.each(&blk)
58
+
59
+ break unless page.next_page?
60
+ page = page.next_page
61
+ end
62
+ end
63
+
64
+ # @api private
65
+ #
66
+ # @param client [SurgeAPI::Internal::Transport::BaseClient]
67
+ # @param req [Hash{Symbol=>Object}]
68
+ # @param headers [Hash{String=>String}]
69
+ # @param page_data [Hash{Symbol=>Object}]
70
+ def initialize(client:, req:, headers:, page_data:)
71
+ super
72
+
73
+ case page_data
74
+ in {data: Array => data}
75
+ @data = data.map { SurgeAPI::Internal::Type::Converter.coerce(@model, _1) }
76
+ else
77
+ end
78
+ case page_data
79
+ in {pagination: Hash | nil => pagination}
80
+ @pagination =
81
+ SurgeAPI::Internal::Type::Converter.coerce(SurgeAPI::Internal::Cursor::Pagination, pagination)
82
+ else
83
+ end
84
+ end
85
+
86
+ # @api private
87
+ #
88
+ # @return [String]
89
+ def inspect
90
+ model = SurgeAPI::Internal::Type::Converter.inspect(@model, depth: 1)
91
+
92
+ "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>"
93
+ end
94
+
95
+ class Pagination < SurgeAPI::Internal::Type::BaseModel
96
+ # @!attribute next_cursor
97
+ #
98
+ # @return [String, nil]
99
+ optional :next_cursor, String
100
+
101
+ # @!attribute previous_cursor
102
+ #
103
+ # @return [String, nil]
104
+ optional :previous_cursor, String
105
+
106
+ # @!method initialize(next_cursor: nil, previous_cursor: nil)
107
+ # @param next_cursor [String]
108
+ # @param previous_cursor [String]
109
+ end
110
+ end
111
+ end
112
+ end
@@ -75,7 +75,7 @@ module SurgeAPI
75
75
 
76
76
  case body
77
77
  in nil
78
- nil
78
+ req["content-length"] ||= 0 unless req["transfer-encoding"]
79
79
  in String
80
80
  req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"]
81
81
  req.body_stream = SurgeAPI::Internal::Util::ReadIOAdapter.new(body, &blk)
@@ -19,7 +19,7 @@ module SurgeAPI
19
19
  # The message body.
20
20
  #
21
21
  # @return [String, nil]
22
- optional :body, String
22
+ optional :body, String, nil?: true
23
23
 
24
24
  # @!attribute name
25
25
  # Optional name for the blast.
@@ -40,7 +40,7 @@ module SurgeAPI
40
40
  #
41
41
  # @param attachments [Array<SurgeAPI::Models::Blast::Attachment>]
42
42
  #
43
- # @param body [String] The message body.
43
+ # @param body [String, nil] The message body.
44
44
  #
45
45
  # @param name [String] Optional name for the blast.
46
46
  #
@@ -16,10 +16,10 @@ module SurgeAPI
16
16
  # The message body.
17
17
  #
18
18
  # @return [String, nil]
19
- optional :body, String
19
+ optional :body, String, nil?: true
20
20
 
21
21
  # @!attribute contacts
22
- # @deprecated
22
+ # @deprecated Use `to` to specify recipients instead.
23
23
  #
24
24
  # Deprecated. Use `to` instead.
25
25
  #
@@ -41,7 +41,7 @@ module SurgeAPI
41
41
  optional :name, String
42
42
 
43
43
  # @!attribute segments
44
- # @deprecated
44
+ # @deprecated Use `to` to specify recipients instead.
45
45
  #
46
46
  # Deprecated. Use `to` instead.
47
47
  #
@@ -67,7 +67,7 @@ module SurgeAPI
67
67
  #
68
68
  # @param attachments [Array<SurgeAPI::Models::BlastCreateParams::Attachment>]
69
69
  #
70
- # @param body [String] The message body.
70
+ # @param body [String, nil] The message body.
71
71
  #
72
72
  # @param contacts [Array<String>] Deprecated. Use `to` instead.
73
73
  #
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ # @see SurgeAPI::Resources::Contacts#list
6
+ class ContactListParams < SurgeAPI::Internal::Type::BaseModel
7
+ extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
+ include SurgeAPI::Internal::Type::RequestParameters
9
+
10
+ # @!attribute after
11
+ # Cursor for forward pagination. Use the next_cursor from a previous response.
12
+ #
13
+ # @return [String, nil]
14
+ optional :after, String
15
+
16
+ # @!attribute before
17
+ # Cursor for backward pagination. Use the previous_cursor from a previous
18
+ # response.
19
+ #
20
+ # @return [String, nil]
21
+ optional :before, String
22
+
23
+ # @!method initialize(after: nil, before: nil, request_options: {})
24
+ # Some parameter documentations has been truncated, see
25
+ # {SurgeAPI::Models::ContactListParams} for more details.
26
+ #
27
+ # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
28
+ #
29
+ # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
30
+ #
31
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
32
+ end
33
+ end
34
+ end
@@ -26,7 +26,7 @@ module SurgeAPI
26
26
  # The message body.
27
27
  #
28
28
  # @return [String, nil]
29
- optional :body, String
29
+ optional :body, String, nil?: true
30
30
 
31
31
  # @!attribute conversation
32
32
  # A conversation with a Contact
@@ -52,7 +52,7 @@ module SurgeAPI
52
52
  #
53
53
  # @param blast_id [String] The ID of the blast this message belongs to, if any. This can be used to attribu
54
54
  #
55
- # @param body [String] The message body.
55
+ # @param body [String, nil] The message body.
56
56
  #
57
57
  # @param conversation [SurgeAPI::Models::Message::Conversation] A conversation with a Contact
58
58
  #
@@ -47,8 +47,8 @@ module SurgeAPI
47
47
  # @!attribute body
48
48
  # The content of the message
49
49
  #
50
- # @return [String]
51
- required :body, String
50
+ # @return [String, nil]
51
+ required :body, String, nil?: true
52
52
 
53
53
  # @!attribute conversation
54
54
  # The conversation this message belongs to
@@ -84,7 +84,7 @@ module SurgeAPI
84
84
  #
85
85
  # @param id [String] The unique identifier for the message
86
86
  #
87
- # @param body [String] The content of the message
87
+ # @param body [String, nil] The content of the message
88
88
  #
89
89
  # @param conversation [SurgeAPI::Models::MessageDeliveredWebhookEvent::Data::Conversation] The conversation this message belongs to
90
90
  #
@@ -47,8 +47,8 @@ module SurgeAPI
47
47
  # @!attribute body
48
48
  # The content of the message
49
49
  #
50
- # @return [String]
51
- required :body, String
50
+ # @return [String, nil]
51
+ required :body, String, nil?: true
52
52
 
53
53
  # @!attribute conversation
54
54
  # The conversation this message belongs to
@@ -90,7 +90,7 @@ module SurgeAPI
90
90
  #
91
91
  # @param id [String] The unique identifier for the message
92
92
  #
93
- # @param body [String] The content of the message
93
+ # @param body [String, nil] The content of the message
94
94
  #
95
95
  # @param conversation [SurgeAPI::Models::MessageFailedWebhookEvent::Data::Conversation] The conversation this message belongs to
96
96
  #
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ # @see SurgeAPI::Resources::Messages#list
6
+ class MessageListParams < SurgeAPI::Internal::Type::BaseModel
7
+ extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
+ include SurgeAPI::Internal::Type::RequestParameters
9
+
10
+ # @!attribute after
11
+ # Cursor for forward pagination. Use the next_cursor from a previous response.
12
+ #
13
+ # @return [String, nil]
14
+ optional :after, String
15
+
16
+ # @!attribute before
17
+ # Cursor for backward pagination. Use the previous_cursor from a previous
18
+ # response.
19
+ #
20
+ # @return [String, nil]
21
+ optional :before, String
22
+
23
+ # @!method initialize(after: nil, before: nil, request_options: {})
24
+ # Some parameter documentations has been truncated, see
25
+ # {SurgeAPI::Models::MessageListParams} for more details.
26
+ #
27
+ # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
28
+ #
29
+ # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
30
+ #
31
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
32
+ end
33
+ end
34
+ end
@@ -47,8 +47,8 @@ module SurgeAPI
47
47
  # @!attribute body
48
48
  # The content of the message
49
49
  #
50
- # @return [String]
51
- required :body, String
50
+ # @return [String, nil]
51
+ required :body, String, nil?: true
52
52
 
53
53
  # @!attribute conversation
54
54
  # The conversation this message belongs to
@@ -84,7 +84,7 @@ module SurgeAPI
84
84
  #
85
85
  # @param id [String] The unique identifier for the message
86
86
  #
87
- # @param body [String] The content of the message
87
+ # @param body [String, nil] The content of the message
88
88
  #
89
89
  # @param conversation [SurgeAPI::Models::MessageReceivedWebhookEvent::Data::Conversation] The conversation this message belongs to
90
90
  #
@@ -47,8 +47,8 @@ module SurgeAPI
47
47
  # @!attribute body
48
48
  # The content of the message
49
49
  #
50
- # @return [String]
51
- required :body, String
50
+ # @return [String, nil]
51
+ required :body, String, nil?: true
52
52
 
53
53
  # @!attribute conversation
54
54
  # The conversation this message belongs to
@@ -84,7 +84,7 @@ module SurgeAPI
84
84
  #
85
85
  # @param id [String] The unique identifier for the message
86
86
  #
87
- # @param body [String] The content of the message
87
+ # @param body [String, nil] The content of the message
88
88
  #
89
89
  # @param conversation [SurgeAPI::Models::MessageSentWebhookEvent::Data::Conversation] The conversation this message belongs to
90
90
  #
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SurgeAPI
4
4
  module Models
5
- # @see SurgeAPI::Resources::PhoneNumbers#purchase
5
+ # @see SurgeAPI::Resources::PhoneNumbers#list
6
6
  class PhoneNumber < SurgeAPI::Internal::Type::BaseModel
7
7
  # @!attribute id
8
8
  # Unique identifier for the phone number
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ # @see SurgeAPI::Resources::PhoneNumbers#list
6
+ class PhoneNumberListParams < SurgeAPI::Internal::Type::BaseModel
7
+ extend SurgeAPI::Internal::Type::RequestParameters::Converter
8
+ include SurgeAPI::Internal::Type::RequestParameters
9
+
10
+ # @!attribute after
11
+ # Cursor for forward pagination. Use the next_cursor from a previous response.
12
+ #
13
+ # @return [String, nil]
14
+ optional :after, String
15
+
16
+ # @!attribute before
17
+ # Cursor for backward pagination. Use the previous_cursor from a previous
18
+ # response.
19
+ #
20
+ # @return [String, nil]
21
+ optional :before, String
22
+
23
+ # @!method initialize(after: nil, before: nil, request_options: {})
24
+ # Some parameter documentations has been truncated, see
25
+ # {SurgeAPI::Models::PhoneNumberListParams} for more details.
26
+ #
27
+ # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
28
+ #
29
+ # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
30
+ #
31
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}]
32
+ end
33
+ end
34
+ end
@@ -69,6 +69,8 @@ module SurgeAPI
69
69
 
70
70
  ContactCreateParams = SurgeAPI::Models::ContactCreateParams
71
71
 
72
+ ContactListParams = SurgeAPI::Models::ContactListParams
73
+
72
74
  ContactOptedInWebhookEvent = SurgeAPI::Models::ContactOptedInWebhookEvent
73
75
 
74
76
  ContactOptedOutWebhookEvent = SurgeAPI::Models::ContactOptedOutWebhookEvent
@@ -91,6 +93,8 @@ module SurgeAPI
91
93
 
92
94
  MessageFailedWebhookEvent = SurgeAPI::Models::MessageFailedWebhookEvent
93
95
 
96
+ MessageListParams = SurgeAPI::Models::MessageListParams
97
+
94
98
  MessageParams = SurgeAPI::Models::MessageParams
95
99
 
96
100
  MessageReceivedWebhookEvent = SurgeAPI::Models::MessageReceivedWebhookEvent
@@ -103,6 +107,8 @@ module SurgeAPI
103
107
 
104
108
  PhoneNumber = SurgeAPI::Models::PhoneNumber
105
109
 
110
+ PhoneNumberListParams = SurgeAPI::Models::PhoneNumberListParams
111
+
106
112
  PhoneNumberPurchaseParams = SurgeAPI::Models::PhoneNumberPurchaseParams
107
113
 
108
114
  UnwrapWebhookEvent = SurgeAPI::Models::UnwrapWebhookEvent
@@ -14,7 +14,7 @@ module SurgeAPI
14
14
  #
15
15
  # @param attachments [Array<SurgeAPI::Models::BlastCreateParams::Attachment>]
16
16
  #
17
- # @param body [String] The message body.
17
+ # @param body [String, nil] The message body.
18
18
  #
19
19
  # @param contacts [Array<String>] Deprecated. Use `to` instead.
20
20
  #
@@ -88,6 +88,36 @@ module SurgeAPI
88
88
  )
89
89
  end
90
90
 
91
+ # Some parameter documentations has been truncated, see
92
+ # {SurgeAPI::Models::ContactListParams} for more details.
93
+ #
94
+ # List all contacts for an account with cursor-based pagination.
95
+ #
96
+ # @overload list(account_id, after: nil, before: nil, request_options: {})
97
+ #
98
+ # @param account_id [String] The account ID to list contacts for.
99
+ #
100
+ # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
101
+ #
102
+ # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
103
+ #
104
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
105
+ #
106
+ # @return [SurgeAPI::Internal::Cursor<SurgeAPI::Models::Contact>]
107
+ #
108
+ # @see SurgeAPI::Models::ContactListParams
109
+ def list(account_id, params = {})
110
+ parsed, options = SurgeAPI::ContactListParams.dump_request(params)
111
+ @client.request(
112
+ method: :get,
113
+ path: ["accounts/%1$s/contacts", account_id],
114
+ query: parsed,
115
+ page: SurgeAPI::Internal::Cursor,
116
+ model: SurgeAPI::Contact,
117
+ options: options
118
+ )
119
+ end
120
+
91
121
  # @api private
92
122
  #
93
123
  # @param client [SurgeAPI::Client]
@@ -79,6 +79,36 @@ module SurgeAPI
79
79
  )
80
80
  end
81
81
 
82
+ # Some parameter documentations has been truncated, see
83
+ # {SurgeAPI::Models::MessageListParams} for more details.
84
+ #
85
+ # List all messages for an account with cursor-based pagination.
86
+ #
87
+ # @overload list(account_id, after: nil, before: nil, request_options: {})
88
+ #
89
+ # @param account_id [String] The account ID to list messages for.
90
+ #
91
+ # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
92
+ #
93
+ # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
94
+ #
95
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
96
+ #
97
+ # @return [SurgeAPI::Internal::Cursor<SurgeAPI::Models::Message>]
98
+ #
99
+ # @see SurgeAPI::Models::MessageListParams
100
+ def list(account_id, params = {})
101
+ parsed, options = SurgeAPI::MessageListParams.dump_request(params)
102
+ @client.request(
103
+ method: :get,
104
+ path: ["accounts/%1$s/messages", account_id],
105
+ query: parsed,
106
+ page: SurgeAPI::Internal::Cursor,
107
+ model: SurgeAPI::Message,
108
+ options: options
109
+ )
110
+ end
111
+
82
112
  # @api private
83
113
  #
84
114
  # @param client [SurgeAPI::Client]
@@ -3,6 +3,36 @@
3
3
  module SurgeAPI
4
4
  module Resources
5
5
  class PhoneNumbers
6
+ # Some parameter documentations has been truncated, see
7
+ # {SurgeAPI::Models::PhoneNumberListParams} for more details.
8
+ #
9
+ # List all phone numbers for an account with cursor-based pagination.
10
+ #
11
+ # @overload list(account_id, after: nil, before: nil, request_options: {})
12
+ #
13
+ # @param account_id [String] The account ID to list phone numbers for.
14
+ #
15
+ # @param after [String] Cursor for forward pagination. Use the next_cursor from a previous response.
16
+ #
17
+ # @param before [String] Cursor for backward pagination. Use the previous_cursor from a previous response
18
+ #
19
+ # @param request_options [SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil]
20
+ #
21
+ # @return [SurgeAPI::Internal::Cursor<SurgeAPI::Models::PhoneNumber>]
22
+ #
23
+ # @see SurgeAPI::Models::PhoneNumberListParams
24
+ def list(account_id, params = {})
25
+ parsed, options = SurgeAPI::PhoneNumberListParams.dump_request(params)
26
+ @client.request(
27
+ method: :get,
28
+ path: ["accounts/%1$s/phone_numbers", account_id],
29
+ query: parsed,
30
+ page: SurgeAPI::Internal::Cursor,
31
+ model: SurgeAPI::PhoneNumber,
32
+ options: options
33
+ )
34
+ end
35
+
6
36
  # Some parameter documentations has been truncated, see
7
37
  # {SurgeAPI::Models::PhoneNumberPurchaseParams} for more details.
8
38
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SurgeAPI
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
data/lib/surge_api.rb CHANGED
@@ -52,6 +52,7 @@ require_relative "surge_api/errors"
52
52
  require_relative "surge_api/internal/transport/base_client"
53
53
  require_relative "surge_api/internal/transport/pooled_net_requester"
54
54
  require_relative "surge_api/client"
55
+ require_relative "surge_api/internal/cursor"
55
56
  require_relative "surge_api/models/campaign_params"
56
57
  require_relative "surge_api/models/message_params"
57
58
  require_relative "surge_api/models/account"
@@ -68,6 +69,7 @@ require_relative "surge_api/models/campaign_approved_webhook_event"
68
69
  require_relative "surge_api/models/campaign_create_params"
69
70
  require_relative "surge_api/models/contact"
70
71
  require_relative "surge_api/models/contact_create_params"
72
+ require_relative "surge_api/models/contact_list_params"
71
73
  require_relative "surge_api/models/contact_opted_in_webhook_event"
72
74
  require_relative "surge_api/models/contact_opted_out_webhook_event"
73
75
  require_relative "surge_api/models/contact_retrieve_params"
@@ -79,11 +81,13 @@ require_relative "surge_api/models/message"
79
81
  require_relative "surge_api/models/message_create_params"
80
82
  require_relative "surge_api/models/message_delivered_webhook_event"
81
83
  require_relative "surge_api/models/message_failed_webhook_event"
84
+ require_relative "surge_api/models/message_list_params"
82
85
  require_relative "surge_api/models/message_received_webhook_event"
83
86
  require_relative "surge_api/models/message_retrieve_params"
84
87
  require_relative "surge_api/models/message_sent_webhook_event"
85
88
  require_relative "surge_api/models/organization"
86
89
  require_relative "surge_api/models/phone_number"
90
+ require_relative "surge_api/models/phone_number_list_params"
87
91
  require_relative "surge_api/models/phone_number_purchase_params"
88
92
  require_relative "surge_api/models/unwrap_webhook_event"
89
93
  require_relative "surge_api/models/user"