surge_api 0.7.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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -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 +15 -5
  8. data/lib/surge_api/models/contact_list_params.rb +34 -0
  9. data/lib/surge_api/models/message.rb +15 -3
  10. data/lib/surge_api/models/message_delivered_webhook_event.rb +16 -4
  11. data/lib/surge_api/models/message_failed_webhook_event.rb +16 -4
  12. data/lib/surge_api/models/message_list_params.rb +34 -0
  13. data/lib/surge_api/models/message_received_webhook_event.rb +16 -4
  14. data/lib/surge_api/models/message_sent_webhook_event.rb +16 -4
  15. data/lib/surge_api/models/phone_number.rb +2 -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 +4 -2
  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 +18 -6
  27. data/rbi/surge_api/models/contact_list_params.rbi +59 -0
  28. data/rbi/surge_api/models/message.rbi +16 -6
  29. data/rbi/surge_api/models/message_delivered_webhook_event.rbi +19 -6
  30. data/rbi/surge_api/models/message_failed_webhook_event.rbi +19 -6
  31. data/rbi/surge_api/models/message_list_params.rbi +59 -0
  32. data/rbi/surge_api/models/message_received_webhook_event.rbi +19 -6
  33. data/rbi/surge_api/models/message_sent_webhook_event.rbi +19 -6
  34. data/rbi/surge_api/models/phone_number.rbi +2 -0
  35. data/rbi/surge_api/models/phone_number_list_params.rbi +59 -0
  36. data/rbi/surge_api/models.rbi +6 -0
  37. data/rbi/surge_api/resources/blasts.rbi +6 -1
  38. data/rbi/surge_api/resources/contacts.rbi +21 -0
  39. data/rbi/surge_api/resources/messages.rbi +21 -0
  40. data/rbi/surge_api/resources/phone_numbers.rbi +21 -0
  41. data/sig/surge_api/internal/cursor.rbs +28 -0
  42. data/sig/surge_api/models/blast.rbs +4 -6
  43. data/sig/surge_api/models/blast_create_params.rbs +11 -6
  44. data/sig/surge_api/models/contact_list_params.rbs +32 -0
  45. data/sig/surge_api/models/message.rbs +10 -5
  46. data/sig/surge_api/models/message_delivered_webhook_event.rbs +14 -7
  47. data/sig/surge_api/models/message_failed_webhook_event.rbs +14 -7
  48. data/sig/surge_api/models/message_list_params.rbs +32 -0
  49. data/sig/surge_api/models/message_received_webhook_event.rbs +14 -7
  50. data/sig/surge_api/models/message_sent_webhook_event.rbs +14 -7
  51. data/sig/surge_api/models/phone_number.rbs +2 -1
  52. data/sig/surge_api/models/phone_number_list_params.rbs +32 -0
  53. data/sig/surge_api/models.rbs +6 -0
  54. data/sig/surge_api/resources/blasts.rbs +2 -1
  55. data/sig/surge_api/resources/contacts.rbs +7 -0
  56. data/sig/surge_api/resources/messages.rbs +7 -0
  57. data/sig/surge_api/resources/phone_numbers.rbs +7 -0
  58. metadata +14 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e8128de1b743d0dfdea80a3444fe70781bb029f32061761b09b749cd8a1abf7
4
- data.tar.gz: 543611ed65fb81164bd534cd91af8a0c6bc2bf96e5efda155aec5204a57c63ce
3
+ metadata.gz: c8cabbc1ca93255610f86e41e4408ee35552d4755552e0bb63dec43d34e37847
4
+ data.tar.gz: 94fd6a84dd1d08f71b3fb51125010f75d03f824538078a70103213297391c30b
5
5
  SHA512:
6
- metadata.gz: 4b124f0da4f0ee63a4e0d418a16059b1f049b26ca9c1361f712e1bd8890fc73d51d9a930818345e753bb22850442085000c293d4a39f9df891582e87b2b31ff3
7
- data.tar.gz: b1a17edfc1c13106f82f11cd1732984f20e2ec7c5afa0ae055c5f31e795c77c9f307520ba38b411c9dda6687f11f91dcefa4cf61cd2b26a1c0a433b43ab54970
6
+ metadata.gz: cce465d2b1f99e690347727f8e987b6afa07a0cd2eadfb0e0832b1bf1100477ae03592e774c9ee8929d9c2eb5903e820fac12ca0d8d28a6ed1207dcdabc33a3c
7
+ data.tar.gz: 184ca9625b88a0b8366f92f0760e1fd5f53abd52752a4c0284b99429442cc69280b29e9758d94381a0ca4fba98e693f36d083710a17883ad13c4aaae3b83d39b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
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
+
26
+ ## 0.8.0 (2026-01-26)
27
+
28
+ Full Changelog: [v0.7.0...v0.8.0](https://github.com/surgeapi/ruby-sdk/compare/v0.7.0...v0.8.0)
29
+
30
+ ### Features
31
+
32
+ * **api:** api update ([37c4efa](https://github.com/surgeapi/ruby-sdk/commit/37c4efa6bdcad247f43f50a49b59a7b4426d6fc8))
33
+ * **api:** api update ([0caf848](https://github.com/surgeapi/ruby-sdk/commit/0caf848fba60e7cda89b326c51bb7c168ad95187))
34
+ * **api:** api update ([f3c40f2](https://github.com/surgeapi/ruby-sdk/commit/f3c40f28c70eb38a08e4021a24230564edab8592))
35
+
3
36
  ## 0.7.0 (2026-01-18)
4
37
 
5
38
  Full Changelog: [v0.6.0...v0.7.0](https://github.com/surgeapi/ruby-sdk/compare/v0.6.0...v0.7.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.7.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,16 +16,24 @@ 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
  #
26
26
  # @return [Array<String>, nil]
27
27
  optional :contacts, SurgeAPI::Internal::Type::ArrayOf[String]
28
28
 
29
+ # @!attribute from
30
+ # The phone number from which to send the blast. This can be either the phone
31
+ # number in E.164 format or a Surge phone number id. If not provided, the
32
+ # account's default phone number is used.
33
+ #
34
+ # @return [String, nil]
35
+ optional :from, String
36
+
29
37
  # @!attribute name
30
38
  # Optional name for the blast.
31
39
  #
@@ -33,7 +41,7 @@ module SurgeAPI
33
41
  optional :name, String
34
42
 
35
43
  # @!attribute segments
36
- # @deprecated
44
+ # @deprecated Use `to` to specify recipients instead.
37
45
  #
38
46
  # Deprecated. Use `to` instead.
39
47
  #
@@ -53,16 +61,18 @@ module SurgeAPI
53
61
  # @return [Array<String>, nil]
54
62
  optional :to, SurgeAPI::Internal::Type::ArrayOf[String]
55
63
 
56
- # @!method initialize(attachments: nil, body: nil, contacts: nil, name: nil, segments: nil, send_at: nil, to: nil, request_options: {})
64
+ # @!method initialize(attachments: nil, body: nil, contacts: nil, from: nil, name: nil, segments: nil, send_at: nil, to: nil, request_options: {})
57
65
  # Some parameter documentations has been truncated, see
58
66
  # {SurgeAPI::Models::BlastCreateParams} for more details.
59
67
  #
60
68
  # @param attachments [Array<SurgeAPI::Models::BlastCreateParams::Attachment>]
61
69
  #
62
- # @param body [String] The message body.
70
+ # @param body [String, nil] The message body.
63
71
  #
64
72
  # @param contacts [Array<String>] Deprecated. Use `to` instead.
65
73
  #
74
+ # @param from [String] The phone number from which to send the blast. This can be either the phone numb
75
+ #
66
76
  # @param name [String] Optional name for the blast.
67
77
  #
68
78
  # @param segments [Array<String>] Deprecated. Use `to` instead.
@@ -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
@@ -15,11 +15,18 @@ module SurgeAPI
15
15
  # @return [Array<SurgeAPI::Models::Message::Attachment>, nil]
16
16
  optional :attachments, -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::Message::Attachment] }
17
17
 
18
+ # @!attribute blast_id
19
+ # The ID of the blast this message belongs to, if any. This can be used to
20
+ # attribute messages back to a specific blast.
21
+ #
22
+ # @return [String, nil]
23
+ optional :blast_id, String
24
+
18
25
  # @!attribute body
19
26
  # The message body.
20
27
  #
21
28
  # @return [String, nil]
22
- optional :body, String
29
+ optional :body, String, nil?: true
23
30
 
24
31
  # @!attribute conversation
25
32
  # A conversation with a Contact
@@ -33,14 +40,19 @@ module SurgeAPI
33
40
  # @return [Hash{Symbol=>String}, nil]
34
41
  optional :metadata, SurgeAPI::Internal::Type::HashOf[String]
35
42
 
36
- # @!method initialize(id: nil, attachments: nil, body: nil, conversation: nil, metadata: nil)
43
+ # @!method initialize(id: nil, attachments: nil, blast_id: nil, body: nil, conversation: nil, metadata: nil)
44
+ # Some parameter documentations has been truncated, see
45
+ # {SurgeAPI::Models::Message} for more details.
46
+ #
37
47
  # A Message is a communication sent to a Contact.
38
48
  #
39
49
  # @param id [String] Unique identifier for the object.
40
50
  #
41
51
  # @param attachments [Array<SurgeAPI::Models::Message::Attachment>]
42
52
  #
43
- # @param body [String] The message body.
53
+ # @param blast_id [String] The ID of the blast this message belongs to, if any. This can be used to attribu
54
+ #
55
+ # @param body [String, nil] The message body.
44
56
  #
45
57
  # @param conversation [SurgeAPI::Models::Message::Conversation] A conversation with a Contact
46
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
@@ -69,18 +69,30 @@ module SurgeAPI
69
69
  optional :attachments,
70
70
  -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::MessageDeliveredWebhookEvent::Data::Attachment] }
71
71
 
72
- # @!method initialize(id:, body:, conversation:, delivered_at:, attachments: nil)
72
+ # @!attribute blast_id
73
+ # The ID of the blast this message belongs to, if any. This can be used to
74
+ # attribute messages back to a specific blast.
75
+ #
76
+ # @return [String, nil]
77
+ optional :blast_id, String
78
+
79
+ # @!method initialize(id:, body:, conversation:, delivered_at:, attachments: nil, blast_id: nil)
80
+ # Some parameter documentations has been truncated, see
81
+ # {SurgeAPI::Models::MessageDeliveredWebhookEvent::Data} for more details.
82
+ #
73
83
  # The data associated with the event
74
84
  #
75
85
  # @param id [String] The unique identifier for the message
76
86
  #
77
- # @param body [String] The content of the message
87
+ # @param body [String, nil] The content of the message
78
88
  #
79
89
  # @param conversation [SurgeAPI::Models::MessageDeliveredWebhookEvent::Data::Conversation] The conversation this message belongs to
80
90
  #
81
91
  # @param delivered_at [Time] When the message was delivered
82
92
  #
83
93
  # @param attachments [Array<SurgeAPI::Models::MessageDeliveredWebhookEvent::Data::Attachment>] Attachments included with the message
94
+ #
95
+ # @param blast_id [String] The ID of the blast this message belongs to, if any. This can be used to attribu
84
96
 
85
97
  # @see SurgeAPI::Models::MessageDeliveredWebhookEvent::Data#conversation
86
98
  class Conversation < SurgeAPI::Internal::Type::BaseModel
@@ -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
@@ -75,12 +75,22 @@ module SurgeAPI
75
75
  optional :attachments,
76
76
  -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::MessageFailedWebhookEvent::Data::Attachment] }
77
77
 
78
- # @!method initialize(id:, body:, conversation:, failed_at:, failure_reason:, attachments: nil)
78
+ # @!attribute blast_id
79
+ # The ID of the blast this message belongs to, if any. This can be used to
80
+ # attribute messages back to a specific blast.
81
+ #
82
+ # @return [String, nil]
83
+ optional :blast_id, String
84
+
85
+ # @!method initialize(id:, body:, conversation:, failed_at:, failure_reason:, attachments: nil, blast_id: nil)
86
+ # Some parameter documentations has been truncated, see
87
+ # {SurgeAPI::Models::MessageFailedWebhookEvent::Data} for more details.
88
+ #
79
89
  # The data associated with the event
80
90
  #
81
91
  # @param id [String] The unique identifier for the message
82
92
  #
83
- # @param body [String] The content of the message
93
+ # @param body [String, nil] The content of the message
84
94
  #
85
95
  # @param conversation [SurgeAPI::Models::MessageFailedWebhookEvent::Data::Conversation] The conversation this message belongs to
86
96
  #
@@ -89,6 +99,8 @@ module SurgeAPI
89
99
  # @param failure_reason [String] The reason the message failed to be delivered
90
100
  #
91
101
  # @param attachments [Array<SurgeAPI::Models::MessageFailedWebhookEvent::Data::Attachment>] Attachments included with the message
102
+ #
103
+ # @param blast_id [String] The ID of the blast this message belongs to, if any. This can be used to attribu
92
104
 
93
105
  # @see SurgeAPI::Models::MessageFailedWebhookEvent::Data#conversation
94
106
  class Conversation < SurgeAPI::Internal::Type::BaseModel
@@ -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
@@ -69,18 +69,30 @@ module SurgeAPI
69
69
  optional :attachments,
70
70
  -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::MessageReceivedWebhookEvent::Data::Attachment] }
71
71
 
72
- # @!method initialize(id:, body:, conversation:, received_at:, attachments: nil)
72
+ # @!attribute blast_id
73
+ # The ID of the blast this message belongs to, if any. This can be used to
74
+ # attribute messages back to a specific blast.
75
+ #
76
+ # @return [String, nil]
77
+ optional :blast_id, String
78
+
79
+ # @!method initialize(id:, body:, conversation:, received_at:, attachments: nil, blast_id: nil)
80
+ # Some parameter documentations has been truncated, see
81
+ # {SurgeAPI::Models::MessageReceivedWebhookEvent::Data} for more details.
82
+ #
73
83
  # The data associated with the event
74
84
  #
75
85
  # @param id [String] The unique identifier for the message
76
86
  #
77
- # @param body [String] The content of the message
87
+ # @param body [String, nil] The content of the message
78
88
  #
79
89
  # @param conversation [SurgeAPI::Models::MessageReceivedWebhookEvent::Data::Conversation] The conversation this message belongs to
80
90
  #
81
91
  # @param received_at [Time] When the message was received
82
92
  #
83
93
  # @param attachments [Array<SurgeAPI::Models::MessageReceivedWebhookEvent::Data::Attachment>] Attachments included with the message
94
+ #
95
+ # @param blast_id [String] The ID of the blast this message belongs to, if any. This can be used to attribu
84
96
 
85
97
  # @see SurgeAPI::Models::MessageReceivedWebhookEvent::Data#conversation
86
98
  class Conversation < SurgeAPI::Internal::Type::BaseModel
@@ -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
@@ -69,18 +69,30 @@ module SurgeAPI
69
69
  optional :attachments,
70
70
  -> { SurgeAPI::Internal::Type::ArrayOf[SurgeAPI::MessageSentWebhookEvent::Data::Attachment] }
71
71
 
72
- # @!method initialize(id:, body:, conversation:, sent_at:, attachments: nil)
72
+ # @!attribute blast_id
73
+ # The ID of the blast this message belongs to, if any. This can be used to
74
+ # attribute messages back to a specific blast.
75
+ #
76
+ # @return [String, nil]
77
+ optional :blast_id, String
78
+
79
+ # @!method initialize(id:, body:, conversation:, sent_at:, attachments: nil, blast_id: nil)
80
+ # Some parameter documentations has been truncated, see
81
+ # {SurgeAPI::Models::MessageSentWebhookEvent::Data} for more details.
82
+ #
73
83
  # The data associated with the event
74
84
  #
75
85
  # @param id [String] The unique identifier for the message
76
86
  #
77
- # @param body [String] The content of the message
87
+ # @param body [String, nil] The content of the message
78
88
  #
79
89
  # @param conversation [SurgeAPI::Models::MessageSentWebhookEvent::Data::Conversation] The conversation this message belongs to
80
90
  #
81
91
  # @param sent_at [Time] When the message was sent
82
92
  #
83
93
  # @param attachments [Array<SurgeAPI::Models::MessageSentWebhookEvent::Data::Attachment>] Attachments included with the message
94
+ #
95
+ # @param blast_id [String] The ID of the blast this message belongs to, if any. This can be used to attribu
84
96
 
85
97
  # @see SurgeAPI::Models::MessageSentWebhookEvent::Data#conversation
86
98
  class Conversation < SurgeAPI::Internal::Type::BaseModel
@@ -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
@@ -38,6 +38,7 @@ module SurgeAPI
38
38
  extend SurgeAPI::Internal::Type::Enum
39
39
 
40
40
  LOCAL = :local
41
+ SHORT_CODE = :short_code
41
42
  TOLL_FREE = :toll_free
42
43
 
43
44
  # @!method self.values
@@ -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