surge_api 0.1.0 → 0.2.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: bd72992441d9bff1aa161673f62cd5957d2f626eee83f83dfd3f259341377826
4
- data.tar.gz: 37b27a1c5c4aa7406a0c81753b3b93469bb6181055cc3e9c6e4c9737cd2317a0
3
+ metadata.gz: 71252990f4c5eb46dec5222b3dd1307f1c347b59ef3a2c7a1aa6ac646555c920
4
+ data.tar.gz: 671de5440b15ba3455652ffcf8b8f0752c6e4827750a99dcb288bfa26cf65acd
5
5
  SHA512:
6
- metadata.gz: 5482581f94873824fd774a5abcac9fcfb723c168cd3fc84f6f05603cc887e66870b3407f6a1546777c2f82b920ce3fc9c798c8fbc522fa8b42398cc8b10274c0
7
- data.tar.gz: 8897a9b535eeac8e8b995e23e2b7793ecf57474f14d13ded041f4ba91eaa6f9730912ac844287621ff427d8eb7fddff3151e8e1b311745947b81794692ec92c8
6
+ metadata.gz: 4595e79a8c3fccbdf83430c0242b378b70acb7f52471a5177e9b78542889f310c62c8d5a6d41515a8cfd6ef72df9a298428274645b0b38f8f61eeb42ea0a3c57
7
+ data.tar.gz: 538a4232414a89f66dd781f0bda3a4e8257cdf9a88d7a07d3efef95345a26a93f895d696b54a6ff3c987f29fac2d62abda9e9c44532786d2e145d8b24c3da6b7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0 (2025-10-09)
4
+
5
+ Full Changelog: [v0.1.0...v0.2.0](https://github.com/surgeapi/ruby-sdk/compare/v0.1.0...v0.2.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** api update ([8a7eeeb](https://github.com/surgeapi/ruby-sdk/commit/8a7eeeb4c5248d0f0aa4da399c45d2763b98ba3b))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * always send `filename=...` for multipart requests where a file is expected ([28bdedf](https://github.com/surgeapi/ruby-sdk/commit/28bdedfba8e9bef43abf39e08169bc2bf2edb0e8))
15
+ * coroutine leaks from connection pool ([239043f](https://github.com/surgeapi/ruby-sdk/commit/239043f74e12856fb8e6b2a477ea9bf35945f2f2))
16
+
17
+
18
+ ### Chores
19
+
20
+ * ignore linter error for tests having large collections ([4d89802](https://github.com/surgeapi/ruby-sdk/commit/4d898024ffae04e4f24591b1c54a922e1b6c51f4))
21
+
3
22
  ## 0.1.0 (2025-09-26)
4
23
 
5
24
  Full Changelog: [v0.0.1...v0.1.0](https://github.com/surgeapi/ruby-sdk/compare/v0.0.1...v0.1.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.1.0"
20
+ gem "surge_api", "~> 0.2.0"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -38,18 +38,21 @@ module SurgeAPI
38
38
  def to_yaml(*a) = read.to_yaml(*a)
39
39
 
40
40
  # @param content [Pathname, StringIO, IO, String]
41
- # @param filename [String, nil]
41
+ # @param filename [Pathname, String, nil]
42
42
  # @param content_type [String, nil]
43
43
  def initialize(content, filename: nil, content_type: nil)
44
- @content = content
44
+ @content_type = content_type
45
45
  @filename =
46
- case content
47
- in Pathname
48
- filename.nil? ? content.basename.to_path : ::File.basename(filename)
46
+ case [filename, (@content = content)]
47
+ in [String | Pathname, _]
48
+ ::File.basename(filename)
49
+ in [nil, Pathname]
50
+ content.basename.to_path
51
+ in [nil, IO]
52
+ content.to_path
49
53
  else
50
- filename.nil? ? nil : ::File.basename(filename)
54
+ filename
51
55
  end
52
- @content_type = content_type
53
56
  end
54
57
  end
55
58
  end
@@ -134,9 +134,9 @@ module SurgeAPI
134
134
 
135
135
  # rubocop:disable Metrics/BlockLength
136
136
  enum = Enumerator.new do |y|
137
- with_pool(url, deadline: deadline) do |conn|
138
- next if finished
137
+ next if finished
139
138
 
139
+ with_pool(url, deadline: deadline) do |conn|
140
140
  req, closing = self.class.build_request(request) do
141
141
  self.class.calibrate_socket_timeout(conn, deadline)
142
142
  end
@@ -149,7 +149,7 @@ module SurgeAPI
149
149
 
150
150
  self.class.calibrate_socket_timeout(conn, deadline)
151
151
  conn.request(req) do |rsp|
152
- y << [conn, req, rsp]
152
+ y << [req, rsp]
153
153
  break if finished
154
154
 
155
155
  rsp.read_body do |bytes|
@@ -160,6 +160,8 @@ module SurgeAPI
160
160
  end
161
161
  eof = true
162
162
  end
163
+ ensure
164
+ conn.finish if !eof && conn&.started?
163
165
  end
164
166
  rescue Timeout::Error
165
167
  raise SurgeAPI::Errors::APITimeoutError.new(url: url, request: req)
@@ -168,16 +170,11 @@ module SurgeAPI
168
170
  end
169
171
  # rubocop:enable Metrics/BlockLength
170
172
 
171
- conn, _, response = enum.next
173
+ _, response = enum.next
172
174
  body = SurgeAPI::Internal::Util.fused_enum(enum, external: true) do
173
175
  finished = true
174
- tap do
175
- enum.next
176
- rescue StopIteration
177
- nil
178
- end
176
+ loop { enum.next }
179
177
  ensure
180
- conn.finish if !eof && conn&.started?
181
178
  closing&.call
182
179
  end
183
180
  [Integer(response.code), response, body]
@@ -82,17 +82,20 @@ module SurgeAPI
82
82
  #
83
83
  # @return [Pathname, StringIO, IO, String, Object]
84
84
  def dump(value, state:)
85
- # rubocop:disable Lint/DuplicateBranch
86
85
  case value
86
+ in StringIO | String
87
+ # https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
88
+ # while not required, a filename is recommended, and in practice many servers do expect this
89
+ SurgeAPI::FilePart.new(value, filename: "upload")
87
90
  in IO
88
91
  state[:can_retry] = false
92
+ value.to_path.nil? ? SurgeAPI::FilePart.new(value, filename: "upload") : value
89
93
  in SurgeAPI::FilePart if value.content.is_a?(IO)
90
94
  state[:can_retry] = false
95
+ value
91
96
  else
97
+ value
92
98
  end
93
- # rubocop:enable Lint/DuplicateBranch
94
-
95
- value
96
99
  end
97
100
 
98
101
  # @api private
@@ -12,7 +12,7 @@ module SurgeAPI
12
12
  # puts(unwrap_webhook_event.account_id)
13
13
  # when SurgeAPI::CampaignApprovedWebhookEvent
14
14
  # puts(unwrap_webhook_event.data)
15
- # when SurgeAPI::ConversationCreatedWebhookEvent
15
+ # when SurgeAPI::ContactOptedInWebhookEvent
16
16
  # puts(unwrap_webhook_event.timestamp)
17
17
  # else
18
18
  # puts(unwrap_webhook_event)
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ class ContactOptedInWebhookEvent < SurgeAPI::Internal::Type::BaseModel
6
+ # @!attribute account_id
7
+ # The ID of the account in which this event occurred
8
+ #
9
+ # @return [String]
10
+ required :account_id, String
11
+
12
+ # @!attribute data
13
+ # The data associated with the event
14
+ #
15
+ # @return [SurgeAPI::Models::ContactOptedInWebhookEvent::Data]
16
+ required :data, -> { SurgeAPI::ContactOptedInWebhookEvent::Data }
17
+
18
+ # @!attribute timestamp
19
+ # The timestamp when this event occurred, in ISO8601 format
20
+ #
21
+ # @return [Time]
22
+ required :timestamp, Time
23
+
24
+ # @!attribute type
25
+ # The type of the event. Always `contact.opted_in` for this event.
26
+ #
27
+ # @return [Symbol, :"contact.opted_in"]
28
+ required :type, const: :"contact.opted_in"
29
+
30
+ # @!method initialize(account_id:, data:, timestamp:, type: :"contact.opted_in")
31
+ # @param account_id [String] The ID of the account in which this event occurred
32
+ #
33
+ # @param data [SurgeAPI::Models::ContactOptedInWebhookEvent::Data] The data associated with the event
34
+ #
35
+ # @param timestamp [Time] The timestamp when this event occurred, in ISO8601 format
36
+ #
37
+ # @param type [Symbol, :"contact.opted_in"] The type of the event. Always `contact.opted_in` for this event.
38
+
39
+ # @see SurgeAPI::Models::ContactOptedInWebhookEvent#data
40
+ class Data < SurgeAPI::Internal::Type::BaseModel
41
+ # @!attribute id
42
+ # The unique identifier for the contact
43
+ #
44
+ # @return [String]
45
+ required :id, String
46
+
47
+ # @!method initialize(id:)
48
+ # The data associated with the event
49
+ #
50
+ # @param id [String] The unique identifier for the contact
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ class ContactOptedOutWebhookEvent < SurgeAPI::Internal::Type::BaseModel
6
+ # @!attribute account_id
7
+ # The ID of the account in which this event occurred
8
+ #
9
+ # @return [String]
10
+ required :account_id, String
11
+
12
+ # @!attribute data
13
+ # The data associated with the event
14
+ #
15
+ # @return [SurgeAPI::Models::ContactOptedOutWebhookEvent::Data]
16
+ required :data, -> { SurgeAPI::ContactOptedOutWebhookEvent::Data }
17
+
18
+ # @!attribute timestamp
19
+ # The timestamp when this event occurred, in ISO8601 format
20
+ #
21
+ # @return [Time]
22
+ required :timestamp, Time
23
+
24
+ # @!attribute type
25
+ # The type of the event. Always `contact.opted_out` for this event.
26
+ #
27
+ # @return [Symbol, :"contact.opted_out"]
28
+ required :type, const: :"contact.opted_out"
29
+
30
+ # @!method initialize(account_id:, data:, timestamp:, type: :"contact.opted_out")
31
+ # @param account_id [String] The ID of the account in which this event occurred
32
+ #
33
+ # @param data [SurgeAPI::Models::ContactOptedOutWebhookEvent::Data] The data associated with the event
34
+ #
35
+ # @param timestamp [Time] The timestamp when this event occurred, in ISO8601 format
36
+ #
37
+ # @param type [Symbol, :"contact.opted_out"] The type of the event. Always `contact.opted_out` for this event.
38
+
39
+ # @see SurgeAPI::Models::ContactOptedOutWebhookEvent#data
40
+ class Data < SurgeAPI::Internal::Type::BaseModel
41
+ # @!attribute id
42
+ # The unique identifier for the contact
43
+ #
44
+ # @return [String]
45
+ required :id, String
46
+
47
+ # @!method initialize(id:)
48
+ # The data associated with the event
49
+ #
50
+ # @param id [String] The unique identifier for the contact
51
+ end
52
+ end
53
+ end
54
+ end
@@ -9,6 +9,10 @@ module SurgeAPI
9
9
 
10
10
  variant -> { SurgeAPI::CampaignApprovedWebhookEvent }
11
11
 
12
+ variant -> { SurgeAPI::ContactOptedInWebhookEvent }
13
+
14
+ variant -> { SurgeAPI::ContactOptedOutWebhookEvent }
15
+
12
16
  variant -> { SurgeAPI::ConversationCreatedWebhookEvent }
13
17
 
14
18
  variant -> { SurgeAPI::MessageDeliveredWebhookEvent }
@@ -20,7 +24,7 @@ module SurgeAPI
20
24
  variant -> { SurgeAPI::MessageSentWebhookEvent }
21
25
 
22
26
  # @!method self.variants
23
- # @return [Array(SurgeAPI::Models::CallEndedWebhookEvent, SurgeAPI::Models::CampaignApprovedWebhookEvent, SurgeAPI::Models::ConversationCreatedWebhookEvent, SurgeAPI::Models::MessageDeliveredWebhookEvent, SurgeAPI::Models::MessageFailedWebhookEvent, SurgeAPI::Models::MessageReceivedWebhookEvent, SurgeAPI::Models::MessageSentWebhookEvent)]
27
+ # @return [Array(SurgeAPI::Models::CallEndedWebhookEvent, SurgeAPI::Models::CampaignApprovedWebhookEvent, SurgeAPI::Models::ContactOptedInWebhookEvent, SurgeAPI::Models::ContactOptedOutWebhookEvent, SurgeAPI::Models::ConversationCreatedWebhookEvent, SurgeAPI::Models::MessageDeliveredWebhookEvent, SurgeAPI::Models::MessageFailedWebhookEvent, SurgeAPI::Models::MessageReceivedWebhookEvent, SurgeAPI::Models::MessageSentWebhookEvent)]
24
28
  end
25
29
  end
26
30
  end
@@ -65,6 +65,10 @@ module SurgeAPI
65
65
 
66
66
  ContactCreateParams = SurgeAPI::Models::ContactCreateParams
67
67
 
68
+ ContactOptedInWebhookEvent = SurgeAPI::Models::ContactOptedInWebhookEvent
69
+
70
+ ContactOptedOutWebhookEvent = SurgeAPI::Models::ContactOptedOutWebhookEvent
71
+
68
72
  ContactRetrieveParams = SurgeAPI::Models::ContactRetrieveParams
69
73
 
70
74
  ContactUpdateParams = SurgeAPI::Models::ContactUpdateParams
@@ -5,7 +5,7 @@ module SurgeAPI
5
5
  class Webhooks
6
6
  # @param payload [String] The raw webhook payload as a string
7
7
  #
8
- # @return [SurgeAPI::Models::CallEndedWebhookEvent, SurgeAPI::Models::CampaignApprovedWebhookEvent, SurgeAPI::Models::ConversationCreatedWebhookEvent, SurgeAPI::Models::MessageDeliveredWebhookEvent, SurgeAPI::Models::MessageFailedWebhookEvent, SurgeAPI::Models::MessageReceivedWebhookEvent, SurgeAPI::Models::MessageSentWebhookEvent]
8
+ # @return [SurgeAPI::Models::CallEndedWebhookEvent, SurgeAPI::Models::CampaignApprovedWebhookEvent, SurgeAPI::Models::ContactOptedInWebhookEvent, SurgeAPI::Models::ContactOptedOutWebhookEvent, SurgeAPI::Models::ConversationCreatedWebhookEvent, SurgeAPI::Models::MessageDeliveredWebhookEvent, SurgeAPI::Models::MessageFailedWebhookEvent, SurgeAPI::Models::MessageReceivedWebhookEvent, SurgeAPI::Models::MessageSentWebhookEvent]
9
9
  def unwrap(payload)
10
10
  parsed = JSON.parse(payload, symbolize_names: true)
11
11
  SurgeAPI::Internal::Type::Converter.coerce(SurgeAPI::Models::UnwrapWebhookEvent, parsed)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SurgeAPI
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/surge_api.rb CHANGED
@@ -63,6 +63,8 @@ require_relative "surge_api/models/campaign_approved_webhook_event"
63
63
  require_relative "surge_api/models/campaign_create_params"
64
64
  require_relative "surge_api/models/contact"
65
65
  require_relative "surge_api/models/contact_create_params"
66
+ require_relative "surge_api/models/contact_opted_in_webhook_event"
67
+ require_relative "surge_api/models/contact_opted_out_webhook_event"
66
68
  require_relative "surge_api/models/contact_retrieve_params"
67
69
  require_relative "surge_api/models/contact_update_params"
68
70
  require_relative "surge_api/models/conversation_created_webhook_event"
@@ -27,7 +27,7 @@ module SurgeAPI
27
27
  sig do
28
28
  params(
29
29
  content: T.any(Pathname, StringIO, IO, String),
30
- filename: T.nilable(String),
30
+ filename: T.nilable(T.any(Pathname, String)),
31
31
  content_type: T.nilable(String)
32
32
  ).returns(T.attached_class)
33
33
  end
@@ -0,0 +1,95 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ class ContactOptedInWebhookEvent < SurgeAPI::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ SurgeAPI::ContactOptedInWebhookEvent,
10
+ SurgeAPI::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The ID of the account in which this event occurred
15
+ sig { returns(String) }
16
+ attr_accessor :account_id
17
+
18
+ # The data associated with the event
19
+ sig { returns(SurgeAPI::ContactOptedInWebhookEvent::Data) }
20
+ attr_reader :data
21
+
22
+ sig do
23
+ params(data: SurgeAPI::ContactOptedInWebhookEvent::Data::OrHash).void
24
+ end
25
+ attr_writer :data
26
+
27
+ # The timestamp when this event occurred, in ISO8601 format
28
+ sig { returns(Time) }
29
+ attr_accessor :timestamp
30
+
31
+ # The type of the event. Always `contact.opted_in` for this event.
32
+ sig { returns(Symbol) }
33
+ attr_accessor :type
34
+
35
+ sig do
36
+ params(
37
+ account_id: String,
38
+ data: SurgeAPI::ContactOptedInWebhookEvent::Data::OrHash,
39
+ timestamp: Time,
40
+ type: Symbol
41
+ ).returns(T.attached_class)
42
+ end
43
+ def self.new(
44
+ # The ID of the account in which this event occurred
45
+ account_id:,
46
+ # The data associated with the event
47
+ data:,
48
+ # The timestamp when this event occurred, in ISO8601 format
49
+ timestamp:,
50
+ # The type of the event. Always `contact.opted_in` for this event.
51
+ type: :"contact.opted_in"
52
+ )
53
+ end
54
+
55
+ sig do
56
+ override.returns(
57
+ {
58
+ account_id: String,
59
+ data: SurgeAPI::ContactOptedInWebhookEvent::Data,
60
+ timestamp: Time,
61
+ type: Symbol
62
+ }
63
+ )
64
+ end
65
+ def to_hash
66
+ end
67
+
68
+ class Data < SurgeAPI::Internal::Type::BaseModel
69
+ OrHash =
70
+ T.type_alias do
71
+ T.any(
72
+ SurgeAPI::ContactOptedInWebhookEvent::Data,
73
+ SurgeAPI::Internal::AnyHash
74
+ )
75
+ end
76
+
77
+ # The unique identifier for the contact
78
+ sig { returns(String) }
79
+ attr_accessor :id
80
+
81
+ # The data associated with the event
82
+ sig { params(id: String).returns(T.attached_class) }
83
+ def self.new(
84
+ # The unique identifier for the contact
85
+ id:
86
+ )
87
+ end
88
+
89
+ sig { override.returns({ id: String }) }
90
+ def to_hash
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,95 @@
1
+ # typed: strong
2
+
3
+ module SurgeAPI
4
+ module Models
5
+ class ContactOptedOutWebhookEvent < SurgeAPI::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ SurgeAPI::ContactOptedOutWebhookEvent,
10
+ SurgeAPI::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # The ID of the account in which this event occurred
15
+ sig { returns(String) }
16
+ attr_accessor :account_id
17
+
18
+ # The data associated with the event
19
+ sig { returns(SurgeAPI::ContactOptedOutWebhookEvent::Data) }
20
+ attr_reader :data
21
+
22
+ sig do
23
+ params(data: SurgeAPI::ContactOptedOutWebhookEvent::Data::OrHash).void
24
+ end
25
+ attr_writer :data
26
+
27
+ # The timestamp when this event occurred, in ISO8601 format
28
+ sig { returns(Time) }
29
+ attr_accessor :timestamp
30
+
31
+ # The type of the event. Always `contact.opted_out` for this event.
32
+ sig { returns(Symbol) }
33
+ attr_accessor :type
34
+
35
+ sig do
36
+ params(
37
+ account_id: String,
38
+ data: SurgeAPI::ContactOptedOutWebhookEvent::Data::OrHash,
39
+ timestamp: Time,
40
+ type: Symbol
41
+ ).returns(T.attached_class)
42
+ end
43
+ def self.new(
44
+ # The ID of the account in which this event occurred
45
+ account_id:,
46
+ # The data associated with the event
47
+ data:,
48
+ # The timestamp when this event occurred, in ISO8601 format
49
+ timestamp:,
50
+ # The type of the event. Always `contact.opted_out` for this event.
51
+ type: :"contact.opted_out"
52
+ )
53
+ end
54
+
55
+ sig do
56
+ override.returns(
57
+ {
58
+ account_id: String,
59
+ data: SurgeAPI::ContactOptedOutWebhookEvent::Data,
60
+ timestamp: Time,
61
+ type: Symbol
62
+ }
63
+ )
64
+ end
65
+ def to_hash
66
+ end
67
+
68
+ class Data < SurgeAPI::Internal::Type::BaseModel
69
+ OrHash =
70
+ T.type_alias do
71
+ T.any(
72
+ SurgeAPI::ContactOptedOutWebhookEvent::Data,
73
+ SurgeAPI::Internal::AnyHash
74
+ )
75
+ end
76
+
77
+ # The unique identifier for the contact
78
+ sig { returns(String) }
79
+ attr_accessor :id
80
+
81
+ # The data associated with the event
82
+ sig { params(id: String).returns(T.attached_class) }
83
+ def self.new(
84
+ # The unique identifier for the contact
85
+ id:
86
+ )
87
+ end
88
+
89
+ sig { override.returns({ id: String }) }
90
+ def to_hash
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -10,6 +10,8 @@ module SurgeAPI
10
10
  T.any(
11
11
  SurgeAPI::CallEndedWebhookEvent,
12
12
  SurgeAPI::CampaignApprovedWebhookEvent,
13
+ SurgeAPI::ContactOptedInWebhookEvent,
14
+ SurgeAPI::ContactOptedOutWebhookEvent,
13
15
  SurgeAPI::ConversationCreatedWebhookEvent,
14
16
  SurgeAPI::MessageDeliveredWebhookEvent,
15
17
  SurgeAPI::MessageFailedWebhookEvent,
@@ -27,6 +27,10 @@ module SurgeAPI
27
27
 
28
28
  ContactCreateParams = SurgeAPI::Models::ContactCreateParams
29
29
 
30
+ ContactOptedInWebhookEvent = SurgeAPI::Models::ContactOptedInWebhookEvent
31
+
32
+ ContactOptedOutWebhookEvent = SurgeAPI::Models::ContactOptedOutWebhookEvent
33
+
30
34
  ContactRetrieveParams = SurgeAPI::Models::ContactRetrieveParams
31
35
 
32
36
  ContactUpdateParams = SurgeAPI::Models::ContactUpdateParams
@@ -8,6 +8,8 @@ module SurgeAPI
8
8
  T.any(
9
9
  SurgeAPI::CallEndedWebhookEvent,
10
10
  SurgeAPI::CampaignApprovedWebhookEvent,
11
+ SurgeAPI::ContactOptedInWebhookEvent,
12
+ SurgeAPI::ContactOptedOutWebhookEvent,
11
13
  SurgeAPI::ConversationCreatedWebhookEvent,
12
14
  SurgeAPI::MessageDeliveredWebhookEvent,
13
15
  SurgeAPI::MessageFailedWebhookEvent,
@@ -14,7 +14,7 @@ module SurgeAPI
14
14
 
15
15
  def initialize: (
16
16
  Pathname | StringIO | IO | String content,
17
- ?filename: String?,
17
+ ?filename: (Pathname | String)?,
18
18
  ?content_type: String?
19
19
  ) -> void
20
20
  end
@@ -0,0 +1,45 @@
1
+ module SurgeAPI
2
+ module Models
3
+ type contact_opted_in_webhook_event =
4
+ {
5
+ account_id: String,
6
+ data: SurgeAPI::ContactOptedInWebhookEvent::Data,
7
+ timestamp: Time,
8
+ type: :"contact.opted_in"
9
+ }
10
+
11
+ class ContactOptedInWebhookEvent < SurgeAPI::Internal::Type::BaseModel
12
+ attr_accessor account_id: String
13
+
14
+ attr_accessor data: SurgeAPI::ContactOptedInWebhookEvent::Data
15
+
16
+ attr_accessor timestamp: Time
17
+
18
+ attr_accessor type: :"contact.opted_in"
19
+
20
+ def initialize: (
21
+ account_id: String,
22
+ data: SurgeAPI::ContactOptedInWebhookEvent::Data,
23
+ timestamp: Time,
24
+ ?type: :"contact.opted_in"
25
+ ) -> void
26
+
27
+ def to_hash: -> {
28
+ account_id: String,
29
+ data: SurgeAPI::ContactOptedInWebhookEvent::Data,
30
+ timestamp: Time,
31
+ type: :"contact.opted_in"
32
+ }
33
+
34
+ type data = { id: String }
35
+
36
+ class Data < SurgeAPI::Internal::Type::BaseModel
37
+ attr_accessor id: String
38
+
39
+ def initialize: (id: String) -> void
40
+
41
+ def to_hash: -> { id: String }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ module SurgeAPI
2
+ module Models
3
+ type contact_opted_out_webhook_event =
4
+ {
5
+ account_id: String,
6
+ data: SurgeAPI::ContactOptedOutWebhookEvent::Data,
7
+ timestamp: Time,
8
+ type: :"contact.opted_out"
9
+ }
10
+
11
+ class ContactOptedOutWebhookEvent < SurgeAPI::Internal::Type::BaseModel
12
+ attr_accessor account_id: String
13
+
14
+ attr_accessor data: SurgeAPI::ContactOptedOutWebhookEvent::Data
15
+
16
+ attr_accessor timestamp: Time
17
+
18
+ attr_accessor type: :"contact.opted_out"
19
+
20
+ def initialize: (
21
+ account_id: String,
22
+ data: SurgeAPI::ContactOptedOutWebhookEvent::Data,
23
+ timestamp: Time,
24
+ ?type: :"contact.opted_out"
25
+ ) -> void
26
+
27
+ def to_hash: -> {
28
+ account_id: String,
29
+ data: SurgeAPI::ContactOptedOutWebhookEvent::Data,
30
+ timestamp: Time,
31
+ type: :"contact.opted_out"
32
+ }
33
+
34
+ type data = { id: String }
35
+
36
+ class Data < SurgeAPI::Internal::Type::BaseModel
37
+ attr_accessor id: String
38
+
39
+ def initialize: (id: String) -> void
40
+
41
+ def to_hash: -> { id: String }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -3,6 +3,8 @@ module SurgeAPI
3
3
  type unwrap_webhook_event =
4
4
  SurgeAPI::CallEndedWebhookEvent
5
5
  | SurgeAPI::CampaignApprovedWebhookEvent
6
+ | SurgeAPI::ContactOptedInWebhookEvent
7
+ | SurgeAPI::ContactOptedOutWebhookEvent
6
8
  | SurgeAPI::ConversationCreatedWebhookEvent
7
9
  | SurgeAPI::MessageDeliveredWebhookEvent
8
10
  | SurgeAPI::MessageFailedWebhookEvent
@@ -25,6 +25,10 @@ module SurgeAPI
25
25
 
26
26
  class ContactCreateParams = SurgeAPI::Models::ContactCreateParams
27
27
 
28
+ class ContactOptedInWebhookEvent = SurgeAPI::Models::ContactOptedInWebhookEvent
29
+
30
+ class ContactOptedOutWebhookEvent = SurgeAPI::Models::ContactOptedOutWebhookEvent
31
+
28
32
  class ContactRetrieveParams = SurgeAPI::Models::ContactRetrieveParams
29
33
 
30
34
  class ContactUpdateParams = SurgeAPI::Models::ContactUpdateParams
@@ -5,6 +5,8 @@ module SurgeAPI
5
5
  String payload
6
6
  ) -> (SurgeAPI::CallEndedWebhookEvent
7
7
  | SurgeAPI::CampaignApprovedWebhookEvent
8
+ | SurgeAPI::ContactOptedInWebhookEvent
9
+ | SurgeAPI::ContactOptedOutWebhookEvent
8
10
  | SurgeAPI::ConversationCreatedWebhookEvent
9
11
  | SurgeAPI::MessageDeliveredWebhookEvent
10
12
  | SurgeAPI::MessageFailedWebhookEvent
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: surge_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Surge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-26 00:00:00.000000000 Z
11
+ date: 2025-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -68,6 +68,8 @@ files:
68
68
  - lib/surge_api/models/campaign_create_params.rb
69
69
  - lib/surge_api/models/contact.rb
70
70
  - lib/surge_api/models/contact_create_params.rb
71
+ - lib/surge_api/models/contact_opted_in_webhook_event.rb
72
+ - lib/surge_api/models/contact_opted_out_webhook_event.rb
71
73
  - lib/surge_api/models/contact_retrieve_params.rb
72
74
  - lib/surge_api/models/contact_update_params.rb
73
75
  - lib/surge_api/models/conversation_created_webhook_event.rb
@@ -137,6 +139,8 @@ files:
137
139
  - rbi/surge_api/models/campaign_create_params.rbi
138
140
  - rbi/surge_api/models/contact.rbi
139
141
  - rbi/surge_api/models/contact_create_params.rbi
142
+ - rbi/surge_api/models/contact_opted_in_webhook_event.rbi
143
+ - rbi/surge_api/models/contact_opted_out_webhook_event.rbi
140
144
  - rbi/surge_api/models/contact_retrieve_params.rbi
141
145
  - rbi/surge_api/models/contact_update_params.rbi
142
146
  - rbi/surge_api/models/conversation_created_webhook_event.rbi
@@ -205,6 +209,8 @@ files:
205
209
  - sig/surge_api/models/campaign_create_params.rbs
206
210
  - sig/surge_api/models/contact.rbs
207
211
  - sig/surge_api/models/contact_create_params.rbs
212
+ - sig/surge_api/models/contact_opted_in_webhook_event.rbs
213
+ - sig/surge_api/models/contact_opted_out_webhook_event.rbs
208
214
  - sig/surge_api/models/contact_retrieve_params.rbs
209
215
  - sig/surge_api/models/contact_update_params.rbs
210
216
  - sig/surge_api/models/conversation_created_webhook_event.rbs