svix 2.3.0 → 2.5.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/svix/api/autoconfig_subscription.rb +38 -0
  4. data/lib/svix/api/destination.rb +75 -0
  5. data/lib/svix/api/destination_transformation.rb +30 -0
  6. data/lib/svix/api_internal/autoconfig_subscription.rb +25 -0
  7. data/lib/svix/api_internal/autoconfig_subscription_destination.rb +22 -0
  8. data/lib/svix/api_internal/autoconfig_subscription_endpoint.rb +22 -0
  9. data/lib/svix/api_internal/endpoint.rb +2 -2
  10. data/lib/svix/api_internal/{endpoint_auto_config.rb → endpoint_auto_config_deprecated.rb} +1 -1
  11. data/lib/svix/autoconfig.rb +53 -18
  12. data/lib/svix/autoconfig_consumer.rb +71 -9
  13. data/lib/svix/models/auto_config_out.rb +53 -0
  14. data/lib/svix/models/auto_config_sink_type.rb +1 -5
  15. data/lib/svix/models/auto_config_subscription_out.rb +67 -0
  16. data/lib/svix/models/destination_in.rb +204 -0
  17. data/lib/svix/models/destination_out.rb +224 -0
  18. data/lib/svix/models/destination_patch.rb +190 -0
  19. data/lib/svix/models/destination_status.rb +31 -0
  20. data/lib/svix/models/destination_status_in.rb +29 -0
  21. data/lib/svix/models/destination_transform_in.rb +49 -0
  22. data/lib/svix/models/destination_transformation_out.rb +52 -0
  23. data/lib/svix/models/event_bridge_config_in.rb +21 -3
  24. data/lib/svix/models/event_bridge_config_out.rb +7 -1
  25. data/lib/svix/models/event_bridge_config_patch.rb +15 -1
  26. data/lib/svix/models/fifo_endpoint_config_in.rb +52 -0
  27. data/lib/svix/models/ingest_source_in.rb +6 -5
  28. data/lib/svix/models/ingest_source_out.rb +6 -5
  29. data/lib/svix/models/list_response_destination_out.rb +58 -0
  30. data/lib/svix/models/merge_config.rb +46 -0
  31. data/lib/svix/models/merge_config_out.rb +43 -0
  32. data/lib/svix/models/redshift_config_in.rb +14 -2
  33. data/lib/svix/models/redshift_config_out.rb +8 -0
  34. data/lib/svix/models/redshift_config_patch.rb +16 -1
  35. data/lib/svix/models/rotate_subscription_in2.rb +52 -0
  36. data/lib/svix/models/s3_config_in.rb +1 -1
  37. data/lib/svix/models/sns_config_in.rb +21 -3
  38. data/lib/svix/models/sns_config_out.rb +7 -1
  39. data/lib/svix/models/sns_config_patch.rb +15 -1
  40. data/lib/svix/models/sqs_config_in.rb +21 -3
  41. data/lib/svix/models/sqs_config_out.rb +7 -1
  42. data/lib/svix/models/sqs_config_patch.rb +15 -1
  43. data/lib/svix/models/status.rb +29 -0
  44. data/lib/svix/models/stream_sink_in.rb +1 -5
  45. data/lib/svix/models/stream_sink_out.rb +18 -5
  46. data/lib/svix/models/stream_sink_patch.rb +1 -5
  47. data/lib/svix/svix.rb +4 -0
  48. data/lib/svix/version.rb +1 -1
  49. data/lib/svix.rb +16 -0
  50. metadata +24 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28418c4e22fca2b9c9662ed348bd66c3d99c7ffa31e287d6cadd9fa93cc7dcc6
4
- data.tar.gz: 91dd99b8777dc77f50a3053242d4aa62e004418af782a69161f7fe2c2f2652f2
3
+ metadata.gz: 9c4cf7c0e89f379a6cafd236e2717d983f33e7467f26ca89c0241291e30d8450
4
+ data.tar.gz: 59b79417b1cf82be9fb9f8e9d980af3e5f0ba5e36eaf10b1691c84c64600af3e
5
5
  SHA512:
6
- metadata.gz: b0549afd5c97e63963c23d7aa464c77e8e4b6e6c28d94e00e0d488bdf4746e19283e5adb96d0e5f871d2fed81ffac491a42a60457fed4958a340edd21fff36bf
7
- data.tar.gz: 2a553ce3e534a831c101383fc0022b59679bf9fae0732e8f83225597804d4983064f630291cab9a42da645e20d1a22171180e9db6d8b012ff5d1aa132cc35c72
6
+ metadata.gz: 33d8911121c6a7aad4d8ceb587ccb29733116cb34f27ae62ea77ce92c5727c3b02f81cba42d505505e1603982fc520f7e032cb33320161fd48f0cd2b43eaa793
7
+ data.tar.gz: bf9e8d998a8fb175d77cc4744aa1f9634c7ab09411dbcc74b607f0878d4bcf02aaf9ed1a46de04354aa5a6c85ebf593f47c84cf39e0dbfad94cbda375d972e5b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- svix (2.3.0)
4
+ svix (2.5.0)
5
5
  base64 (~> 0.3.0)
6
6
  logger (~> 1.0)
7
7
 
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+
4
+ require "net/http"
5
+
6
+ module Svix
7
+ class AutoconfigSubscription
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def create(app_id, options = {})
13
+ options = options.transform_keys(&:to_s)
14
+ res = @client.execute_request(
15
+ "POST",
16
+ "/api/v1/app/#{app_id}/autoconfig",
17
+ headers: {
18
+ "idempotency-key" => options["idempotency-key"]
19
+ }
20
+ )
21
+ AutoConfigOut.deserialize(res)
22
+ end
23
+
24
+ def rotate(app_id, autoconfig_id, rotate_subscription_in2, options = {})
25
+ options = options.transform_keys(&:to_s)
26
+ res = @client.execute_request(
27
+ "POST",
28
+ "/api/v1/app/#{app_id}/autoconfig/#{autoconfig_id}/rotate",
29
+ headers: {
30
+ "idempotency-key" => options["idempotency-key"]
31
+ },
32
+ body: rotate_subscription_in2
33
+ )
34
+ AutoConfigOut.deserialize(res)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+
4
+ require "net/http"
5
+
6
+ module Svix
7
+ class Destination
8
+ attr_accessor :transformation
9
+ def initialize(client)
10
+ @client = client
11
+ @transformation = DestinationTransformation.new(client)
12
+ end
13
+
14
+ def list(app_id, options = {})
15
+ options = options.transform_keys(&:to_s)
16
+ res = @client.execute_request(
17
+ "GET",
18
+ "/api/v1/app/#{app_id}/destination",
19
+ query_params: {
20
+ "limit" => options["limit"],
21
+ "iterator" => options["iterator"],
22
+ "order" => options["order"]
23
+ }
24
+ )
25
+ ListResponseDestinationOut.deserialize(res)
26
+ end
27
+
28
+ def create(app_id, destination_in, options = {})
29
+ options = options.transform_keys(&:to_s)
30
+ res = @client.execute_request(
31
+ "POST",
32
+ "/api/v1/app/#{app_id}/destination",
33
+ headers: {
34
+ "idempotency-key" => options["idempotency-key"]
35
+ },
36
+ body: destination_in
37
+ )
38
+ DestinationOut.deserialize(res)
39
+ end
40
+
41
+ def get(app_id, destination_id)
42
+ res = @client.execute_request(
43
+ "GET",
44
+ "/api/v1/app/#{app_id}/destination/#{destination_id}"
45
+ )
46
+ DestinationOut.deserialize(res)
47
+ end
48
+
49
+ def upsert(app_id, destination_id, destination_in)
50
+ res = @client.execute_request(
51
+ "PUT",
52
+ "/api/v1/app/#{app_id}/destination/#{destination_id}",
53
+ body: destination_in
54
+ )
55
+ DestinationOut.deserialize(res)
56
+ end
57
+
58
+ def delete(app_id, destination_id)
59
+ @client.execute_request(
60
+ "DELETE",
61
+ "/api/v1/app/#{app_id}/destination/#{destination_id}"
62
+ )
63
+ end
64
+
65
+ def patch(app_id, destination_id, destination_patch)
66
+ res = @client.execute_request(
67
+ "PATCH",
68
+ "/api/v1/app/#{app_id}/destination/#{destination_id}",
69
+ body: destination_patch
70
+ )
71
+ DestinationOut.deserialize(res)
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+
4
+ require "net/http"
5
+
6
+ module Svix
7
+ class DestinationTransformation
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def get(app_id, destination_id)
13
+ res = @client.execute_request(
14
+ "GET",
15
+ "/api/v1/app/#{app_id}/destination/#{destination_id}/transformation"
16
+ )
17
+ DestinationTransformationOut.deserialize(res)
18
+ end
19
+
20
+ def patch(app_id, destination_id, destination_transform_in)
21
+ res = @client.execute_request(
22
+ "PATCH",
23
+ "/api/v1/app/#{app_id}/destination/#{destination_id}/transformation",
24
+ body: destination_transform_in
25
+ )
26
+ EmptyResponse.deserialize(res)
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+
4
+ require "net/http"
5
+
6
+ module Svix
7
+ class AutoconfigSubscription
8
+ attr_accessor :destination
9
+ attr_accessor :endpoint
10
+ def initialize(client)
11
+ @client = client
12
+ @destination = AutoconfigSubscriptionDestination.new(client)
13
+ @endpoint = AutoconfigSubscriptionEndpoint.new(client)
14
+ end
15
+
16
+ def get(app_id, autoconfig_id)
17
+ res = @client.execute_request(
18
+ "GET",
19
+ "/api/v1/app/#{app_id}/autoconfig/#{autoconfig_id}"
20
+ )
21
+ AutoConfigSubscriptionOut.deserialize(res)
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+
4
+ require "net/http"
5
+
6
+ module Svix
7
+ class AutoconfigSubscriptionDestination
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def subscribe(app_id, autoconfig_id, destination_in)
13
+ res = @client.execute_request(
14
+ "PUT",
15
+ "/api/v1/app/#{app_id}/autoconfig/#{autoconfig_id}/destination",
16
+ body: destination_in
17
+ )
18
+ DestinationOut.deserialize(res)
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+
4
+ require "net/http"
5
+
6
+ module Svix
7
+ class AutoconfigSubscriptionEndpoint
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def subscribe(app_id, autoconfig_id, endpoint_in)
13
+ res = @client.execute_request(
14
+ "PUT",
15
+ "/api/v1/app/#{app_id}/autoconfig/#{autoconfig_id}/endpoint",
16
+ body: endpoint_in
17
+ )
18
+ EndpointOut.deserialize(res)
19
+ end
20
+
21
+ end
22
+ end
@@ -5,10 +5,10 @@ require "net/http"
5
5
 
6
6
  module Svix
7
7
  class Endpoint
8
- attr_accessor :auto_config
8
+ attr_accessor :auto_config_deprecated
9
9
  def initialize(client)
10
10
  @client = client
11
- @auto_config = EndpointAutoConfig.new(client)
11
+ @auto_config_deprecated = EndpointAutoConfigDeprecated.new(client)
12
12
  end
13
13
 
14
14
  def transformation_partial_update(app_id, endpoint_id, endpoint_transformation_in)
@@ -4,7 +4,7 @@
4
4
  require "net/http"
5
5
 
6
6
  module Svix
7
- class EndpointAutoConfig
7
+ class EndpointAutoConfigDeprecated
8
8
  def initialize(client)
9
9
  @client = client
10
10
  end
@@ -5,11 +5,15 @@ require "base64"
5
5
  require "uri"
6
6
 
7
7
  require "svix/models/subscribe_in"
8
- require "svix/api_internal/endpoint_auto_config"
8
+ require "svix/api_internal/endpoint_auto_config_deprecated"
9
+ require "svix/api_internal/autoconfig_subscription"
10
+ require "svix/api_internal/autoconfig_subscription_destination"
11
+ require "svix/api_internal/autoconfig_subscription_endpoint"
9
12
 
10
13
  module Svix
11
14
  class AutoConfig
12
15
  AUTOCONFIG_TOKEN_PREFIX_V1 = "auto_v1_"
16
+ AUTOCONFIG_TOKEN_PREFIX_V2 = "auto_v2_"
13
17
  UNSUPPORTED_TOKEN_VERSION = "Unsupported token version. You might need to update the Svix SDK to use this token"
14
18
 
15
19
  class InvalidTokenError < StandardError; end
@@ -19,7 +23,8 @@ module Svix
19
23
  def initialize(token, endpoint_in)
20
24
  content = AutoConfig.decode_token!(token)
21
25
  @app_id = content.fetch("app_id")
22
- @endpoint_id = content.fetch("endpoint_id")
26
+ @endpoint_id = content["endpoint_id"]
27
+ @autoconfig_id = content["autoconfig_id"]
23
28
  @endpoint = endpoint_in
24
29
  @webhook = Webhook.new(content.fetch("endpoint_secret"))
25
30
  @client = SvixHttpClient.new(
@@ -29,11 +34,19 @@ module Svix
29
34
  end
30
35
 
31
36
  def subscribe
32
- EndpointAutoConfig.new(@client).update(
33
- @app_id,
34
- @endpoint_id,
35
- SubscribeIn.new("endpoint" => @endpoint)
36
- )
37
+ if @autoconfig_id
38
+ AutoconfigSubscription.new(@client).endpoint.subscribe(
39
+ @app_id,
40
+ @autoconfig_id,
41
+ @endpoint
42
+ )
43
+ else
44
+ EndpointAutoConfigDeprecated.new(@client).update(
45
+ @app_id,
46
+ @endpoint_id,
47
+ SubscribeIn.new("endpoint" => @endpoint)
48
+ )
49
+ end
37
50
  end
38
51
 
39
52
  def verify(payload, headers)
@@ -42,26 +55,48 @@ module Svix
42
55
 
43
56
  class << self
44
57
  def decode_token!(token)
45
- unless token.is_a?(String) && token.start_with?(AUTOCONFIG_TOKEN_PREFIX_V1)
58
+ unless token.is_a?(String)
46
59
  raise InvalidTokenError, UNSUPPORTED_TOKEN_VERSION
47
60
  end
48
61
 
49
- encoded = token.byteslice(AUTOCONFIG_TOKEN_PREFIX_V1.length..-1)
62
+ if token.start_with?(AUTOCONFIG_TOKEN_PREFIX_V1)
63
+ data = parse_token_payload!(token, AUTOCONFIG_TOKEN_PREFIX_V1)
64
+ {
65
+ "version" => "v1",
66
+ "app_id" => data.fetch("aid"),
67
+ "endpoint_id" => data.fetch("eid"),
68
+ "server_url" => data.fetch("surl"),
69
+ "endpoint_secret" => data.fetch("esec"),
70
+ "token_plaintext" => data.fetch("tok"),
71
+ }
72
+ elsif token.start_with?(AUTOCONFIG_TOKEN_PREFIX_V2)
73
+ data = parse_token_payload!(token, AUTOCONFIG_TOKEN_PREFIX_V2)
74
+ {
75
+ "version" => "v2",
76
+ "app_id" => data.fetch("aid"),
77
+ "autoconfig_id" => data.fetch("sid"),
78
+ "server_url" => data.fetch("surl"),
79
+ "endpoint_secret" => data.fetch("esec"),
80
+ "token_plaintext" => data.fetch("tok"),
81
+ }
82
+ else
83
+ raise InvalidTokenError, UNSUPPORTED_TOKEN_VERSION
84
+ end
85
+ rescue ArgumentError, JSON::ParserError, KeyError, TypeError
86
+ raise InvalidTokenError
87
+ end
88
+
89
+ private
90
+
91
+ def parse_token_payload!(token, prefix)
92
+ encoded = token.byteslice(prefix.length..-1)
50
93
  json = Base64.decode64(encoded)
51
94
  data = JSON.parse(json)
52
95
  unless data.is_a?(Hash)
53
96
  raise InvalidTokenError
54
97
  end
55
98
 
56
- {
57
- "app_id" => data.fetch("aid"),
58
- "endpoint_id" => data.fetch("eid"),
59
- "server_url" => data.fetch("surl"),
60
- "endpoint_secret" => data.fetch("esec"),
61
- "token_plaintext" => data.fetch("tok"),
62
- }
63
- rescue ArgumentError, JSON::ParserError, KeyError, TypeError
64
- raise InvalidTokenError
99
+ data
65
100
  end
66
101
  end
67
102
  end
@@ -1,10 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "uri"
4
+
3
5
  require "svix/models/auto_config_sink_type"
6
+ require "svix/models/auto_config_subscription_out"
7
+ require "svix/models/status"
8
+ require "svix/models/destination_in"
9
+ require "svix/models/destination_out"
4
10
  require "svix/models/poller_v2_commit_in"
5
11
  require "svix/models/sink_in_common"
12
+ require "svix/models/destination_status"
6
13
  require "svix/models/subscribe_in"
7
- require "svix/api_internal/endpoint_auto_config"
14
+ require "svix/api_internal/endpoint_auto_config_deprecated"
15
+ require "svix/api_internal/autoconfig_subscription"
16
+ require "svix/api_internal/autoconfig_subscription_destination"
17
+ require "svix/api_internal/autoconfig_subscription_endpoint"
8
18
  require "svix/api_internal/message_pollerv2"
9
19
 
10
20
  module Svix
@@ -12,7 +22,8 @@ module Svix
12
22
  def initialize(token, sink_in)
13
23
  content = AutoConfig.decode_token!(token)
14
24
  @app_id = content.fetch("app_id")
15
- @sink_id = content.fetch("endpoint_id")
25
+ @sink_id = content["endpoint_id"]
26
+ @autoconfig_id = content["autoconfig_id"]
16
27
  @sink_in = sink_in
17
28
  @client = SvixHttpClient.new(
18
29
  content.fetch("token_plaintext"),
@@ -21,17 +32,28 @@ module Svix
21
32
  end
22
33
 
23
34
  def subscribe
24
- poller = AutoConfigSinkTypeConfig::Poller.new(@sink_in.serialize)
25
- subscribe_in = SubscribeIn.new(
26
- "sink" => AutoConfigSinkType.new("config" => poller)
27
- )
28
- EndpointAutoConfig.new(@client).update(@app_id, @sink_id, subscribe_in)
35
+ if @autoconfig_id
36
+ destination = AutoconfigSubscription.new(@client).destination.subscribe(
37
+ @app_id,
38
+ @autoconfig_id,
39
+ sink_in_common_to_polling_destination(@sink_in)
40
+ )
41
+ @sink_id = destination.id
42
+ destination
43
+ else
44
+ poller = AutoConfigSinkTypeConfig::Poller.deserialize(@sink_in.serialize)
45
+ subscribe_in = SubscribeIn.new(
46
+ "sink" => AutoConfigSinkType.new("config" => poller)
47
+ )
48
+ endpoint = EndpointAutoConfigDeprecated.new(@client).update(@app_id, @sink_id, subscribe_in)
49
+ destination_out_from_v1_endpoint(endpoint)
50
+ end
29
51
  end
30
52
 
31
53
  def receive(consumer_id, options = {})
32
54
  MessagePollerv2.new(@client).consumer_poll(
33
55
  @app_id,
34
- @sink_id,
56
+ sink_id,
35
57
  consumer_id,
36
58
  options
37
59
  )
@@ -40,11 +62,51 @@ module Svix
40
62
  def commit(consumer_id, offset, options = {})
41
63
  MessagePollerv2.new(@client).consumer_commit(
42
64
  @app_id,
43
- @sink_id,
65
+ sink_id,
44
66
  consumer_id,
45
67
  PollerV2CommitIn.new("offset" => offset),
46
68
  options
47
69
  )
48
70
  end
71
+
72
+ private
73
+
74
+ def sink_id
75
+ return @sink_id if @sink_id
76
+
77
+ # Get the sink id from the autoconfig id (v2)
78
+ dest_id = AutoconfigSubscription.new(@client).get(@app_id, @autoconfig_id).dest_id
79
+ raise "autoconfig subscription is pending. Have you called subscribe()?" if dest_id.nil? || dest_id.empty?
80
+
81
+ dest_id
82
+ end
83
+
84
+ def destination_out_from_v1_endpoint(endpoint)
85
+ DestinationOut.new(
86
+ "id" => endpoint.id,
87
+ "uid" => endpoint.uid,
88
+ "status" => endpoint.disabled ? DestinationStatus::DISABLED : DestinationStatus::ENABLED,
89
+ "current_iterator" => "",
90
+ "created_at" => endpoint.created_at,
91
+ "updated_at" => endpoint.updated_at,
92
+ "batch_size" => 0,
93
+ "max_wait_secs" => 0,
94
+ "event_types" => endpoint.event_types,
95
+ "channels" => endpoint.channels,
96
+ "metadata" => endpoint.metadata,
97
+ "config" => DestinationOutConfig::PollingEndpoint.new
98
+ )
99
+ end
100
+
101
+ def sink_in_common_to_polling_destination(sink)
102
+ attrs = {
103
+ "config" => DestinationInConfig::PollingEndpoint.new
104
+ }
105
+ attrs["uid"] = sink.uid unless sink.uid.nil?
106
+ attrs["event_types"] = sink.event_types unless sink.event_types.nil?
107
+ attrs["channels"] = sink.channels unless sink.channels.nil?
108
+ attrs["metadata"] = sink.metadata unless sink.metadata.nil?
109
+ DestinationIn.new(attrs)
110
+ end
49
111
  end
50
112
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module Svix
6
+ class AutoConfigOut
7
+ attr_accessor :created_at
8
+ attr_accessor :token
9
+ # The AutoConfigSubscription's ID.
10
+ attr_accessor :id
11
+
12
+ ALL_FIELD ||= ["created_at", "token", "id"].freeze
13
+ private_constant :ALL_FIELD
14
+
15
+ def initialize(attributes = {})
16
+ unless attributes.is_a?(Hash)
17
+ fail(ArgumentError, "The input argument (attributes) must be a hash in `Svix::AutoConfigOut` new method")
18
+ end
19
+
20
+ attributes.each do |k, v|
21
+ unless ALL_FIELD.include?(k.to_s)
22
+ fail(ArgumentError, "The field #{k} is not part of Svix::AutoConfigOut")
23
+ end
24
+
25
+ instance_variable_set("@#{k}", v)
26
+ instance_variable_set("@__#{k}_is_defined", true)
27
+ end
28
+ end
29
+
30
+ def self.deserialize(attributes = {})
31
+ attributes = attributes.transform_keys(&:to_s)
32
+ attrs = Hash.new
33
+ attrs["created_at"] = DateTime.rfc3339(attributes["createdAt"]).to_time
34
+ attrs["token"] = attributes["token"]
35
+ attrs["id"] = attributes["id"]
36
+ new(attrs)
37
+ end
38
+
39
+ def serialize
40
+ out = Hash.new
41
+ out["createdAt"] = Svix::serialize_primitive(@created_at) unless @created_at.nil?
42
+ out["token"] = Svix::serialize_primitive(@token) unless @token.nil?
43
+ out["id"] = Svix::serialize_primitive(@id) unless @id.nil?
44
+ out
45
+ end
46
+
47
+ # Serializes the object to a json string
48
+ # @return String
49
+ def to_json(*args)
50
+ serialize.to_json(*args)
51
+ end
52
+ end
53
+ end
@@ -64,11 +64,7 @@ module Svix
64
64
  fail(ArgumentError, "Invalid type `#{attributes["type"]}` expected on of #{NAME_TO_TYPE.keys}")
65
65
  end
66
66
 
67
- unless attributes.key?("config")
68
- fail(ArgumentError, "Missing required field config")
69
- end
70
-
71
- attrs["config"] = NAME_TO_TYPE[attributes["type"]].deserialize(attributes["config"])
67
+ attrs["config"] = NAME_TO_TYPE[attributes["type"]].deserialize(attributes["config"] || {})
72
68
  new(attrs)
73
69
  end
74
70
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module Svix
6
+ class AutoConfigSubscriptionOut
7
+ attr_accessor :created_at
8
+ attr_accessor :token_censored
9
+ # The AutoConfigSubscription's ID.
10
+ attr_accessor :id
11
+ # The Endpoint's ID.
12
+ attr_accessor :endp_id
13
+ # The StreamSink's ID.
14
+ attr_accessor :dest_id
15
+ attr_accessor :status
16
+
17
+ ALL_FIELD ||= ["created_at", "token_censored", "id", "endp_id", "dest_id", "status"].freeze
18
+ private_constant :ALL_FIELD
19
+
20
+ def initialize(attributes = {})
21
+ unless attributes.is_a?(Hash)
22
+ fail(
23
+ ArgumentError,
24
+ "The input argument (attributes) must be a hash in `Svix::AutoConfigSubscriptionOut` new method"
25
+ )
26
+ end
27
+
28
+ attributes.each do |k, v|
29
+ unless ALL_FIELD.include?(k.to_s)
30
+ fail(ArgumentError, "The field #{k} is not part of Svix::AutoConfigSubscriptionOut")
31
+ end
32
+
33
+ instance_variable_set("@#{k}", v)
34
+ instance_variable_set("@__#{k}_is_defined", true)
35
+ end
36
+ end
37
+
38
+ def self.deserialize(attributes = {})
39
+ attributes = attributes.transform_keys(&:to_s)
40
+ attrs = Hash.new
41
+ attrs["created_at"] = DateTime.rfc3339(attributes["createdAt"]).to_time
42
+ attrs["token_censored"] = attributes["tokenCensored"]
43
+ attrs["id"] = attributes["id"]
44
+ attrs["endp_id"] = attributes["endpId"]
45
+ attrs["dest_id"] = attributes["destId"]
46
+ attrs["status"] = Svix::Status.deserialize(attributes["status"])
47
+ new(attrs)
48
+ end
49
+
50
+ def serialize
51
+ out = Hash.new
52
+ out["createdAt"] = Svix::serialize_primitive(@created_at) unless @created_at.nil?
53
+ out["tokenCensored"] = Svix::serialize_primitive(@token_censored) unless @token_censored.nil?
54
+ out["id"] = Svix::serialize_primitive(@id) unless @id.nil?
55
+ out["endpId"] = Svix::serialize_primitive(@endp_id) unless @endp_id.nil?
56
+ out["destId"] = Svix::serialize_primitive(@dest_id) unless @dest_id.nil?
57
+ out["status"] = Svix::serialize_schema_ref(@status) unless @status.nil?
58
+ out
59
+ end
60
+
61
+ # Serializes the object to a json string
62
+ # @return String
63
+ def to_json(*args)
64
+ serialize.to_json(*args)
65
+ end
66
+ end
67
+ end