agentic-commerce-protocol 0.1.3 → 0.1.5

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/agentic_commerce_protocol/models/address.rb +67 -0
  3. data/lib/agentic_commerce_protocol/models/allowance.rb +67 -0
  4. data/lib/agentic_commerce_protocol/models/allowance_reason.rb +28 -0
  5. data/lib/agentic_commerce_protocol/models/buyer.rb +58 -0
  6. data/lib/agentic_commerce_protocol/models/card_funding_type.rb +30 -0
  7. data/lib/agentic_commerce_protocol/models/card_number_type.rb +29 -0
  8. data/lib/agentic_commerce_protocol/models/check_performed_type.rb +31 -0
  9. data/lib/agentic_commerce_protocol/models/checkout_session.rb +113 -0
  10. data/lib/agentic_commerce_protocol/models/checkout_session_complete_request.rb +52 -0
  11. data/lib/agentic_commerce_protocol/models/checkout_session_create_request.rb +61 -0
  12. data/lib/agentic_commerce_protocol/models/checkout_session_status.rb +32 -0
  13. data/lib/agentic_commerce_protocol/models/checkout_session_update_request.rb +70 -0
  14. data/lib/agentic_commerce_protocol/models/content_type.rb +29 -0
  15. data/lib/agentic_commerce_protocol/models/delegate_payment_request.rb +64 -0
  16. data/lib/agentic_commerce_protocol/models/delegate_payment_response.rb +55 -0
  17. data/lib/agentic_commerce_protocol/models/error.rb +58 -0
  18. data/lib/agentic_commerce_protocol/models/error_code.rb +33 -0
  19. data/lib/agentic_commerce_protocol/models/error_type.rb +31 -0
  20. data/lib/agentic_commerce_protocol/models/event_data_order.rb +64 -0
  21. data/lib/agentic_commerce_protocol/models/fulfillment_option.rb +89 -0
  22. data/lib/agentic_commerce_protocol/models/fulfillment_option_digital.rb +64 -0
  23. data/lib/agentic_commerce_protocol/models/fulfillment_option_shipping.rb +89 -0
  24. data/lib/agentic_commerce_protocol/models/item.rb +52 -0
  25. data/lib/agentic_commerce_protocol/models/line_item.rb +67 -0
  26. data/lib/agentic_commerce_protocol/models/link.rb +52 -0
  27. data/lib/agentic_commerce_protocol/models/link_type.rb +30 -0
  28. data/lib/agentic_commerce_protocol/models/message.rb +89 -0
  29. data/lib/agentic_commerce_protocol/models/message_error.rb +58 -0
  30. data/lib/agentic_commerce_protocol/models/message_info.rb +55 -0
  31. data/lib/agentic_commerce_protocol/models/order.rb +58 -0
  32. data/lib/agentic_commerce_protocol/models/payment_data.rb +58 -0
  33. data/lib/agentic_commerce_protocol/models/payment_method_card.rb +124 -0
  34. data/lib/agentic_commerce_protocol/models/payment_method_type.rb +28 -0
  35. data/lib/agentic_commerce_protocol/models/payment_provider.rb +57 -0
  36. data/lib/agentic_commerce_protocol/models/payment_provider_type.rb +28 -0
  37. data/lib/agentic_commerce_protocol/models/refund.rb +52 -0
  38. data/lib/agentic_commerce_protocol/models/refund_type.rb +29 -0
  39. data/lib/agentic_commerce_protocol/models/risk_signal.rb +55 -0
  40. data/lib/agentic_commerce_protocol/models/risk_signal_action.rb +30 -0
  41. data/lib/agentic_commerce_protocol/models/risk_signal_type.rb +28 -0
  42. data/lib/agentic_commerce_protocol/models/total.rb +55 -0
  43. data/lib/agentic_commerce_protocol/models/total_type.rb +35 -0
  44. data/lib/agentic_commerce_protocol/models/webhook_event.rb +52 -0
  45. data/lib/agentic_commerce_protocol/models/webhook_event_type.rb +29 -0
  46. data/lib/agentic_commerce_protocol/models/webhook_order_status.rb +33 -0
  47. data/lib/agentic_commerce_protocol/util.rb +70 -0
  48. data/lib/agentic_commerce_protocol/version.rb +2 -1
  49. data/lib/agentic_commerce_protocol.rb +50 -6
  50. metadata +48 -3
  51. data/lib/agentic_commerce_protocol/types.rb +0 -13
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ module AgenticCommerceProtocol
4
+ class ContentType
5
+ PLAIN = "plain".freeze
6
+ MARKDOWN = "markdown".freeze
7
+
8
+ def self.all_vars
9
+ @all_vars ||= [PLAIN, MARKDOWN].freeze
10
+ end
11
+
12
+ def initialize(value)
13
+ unless ContentType.all_vars.include?(value)
14
+ raise "Invalid ENUM value '#{value}' for class #ContentType"
15
+ end
16
+
17
+ @value = value
18
+ end
19
+
20
+ def self.deserialize(value)
21
+ return value if ContentType.all_vars.include?(value)
22
+ raise "Invalid ENUM value '#{value}' for class #ContentType"
23
+ end
24
+
25
+ def serialize
26
+ @value
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module AgenticCommerceProtocol
6
+ class DelegatePaymentRequest
7
+ attr_accessor :payment_method
8
+ attr_accessor :allowance
9
+ attr_accessor :billing_address
10
+ attr_accessor :risk_signals
11
+ attr_accessor :metadata
12
+
13
+ ALL_FIELD ||= ["payment_method", "allowance", "billing_address", "risk_signals", "metadata"].freeze
14
+ private_constant :ALL_FIELD
15
+
16
+ def initialize(attributes = {})
17
+ unless attributes.is_a?(Hash)
18
+ fail(
19
+ ArgumentError,
20
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::DelegatePaymentRequest` new method"
21
+ )
22
+ end
23
+
24
+ attributes.each do |k, v|
25
+ unless ALL_FIELD.include?(k.to_s)
26
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::DelegatePaymentRequest")
27
+ end
28
+
29
+ instance_variable_set("@#{k}", v)
30
+ instance_variable_set("@__#{k}_is_defined", true)
31
+ end
32
+ end
33
+
34
+ def self.deserialize(attributes = {})
35
+ attributes = attributes.transform_keys(&:to_s)
36
+ attrs = Hash.new
37
+ attrs["payment_method"] = AgenticCommerceProtocol::PaymentMethodCard.deserialize(attributes["payment_method"])
38
+ attrs["allowance"] = AgenticCommerceProtocol::Allowance.deserialize(attributes["allowance"])
39
+ if attributes["billing_address"]
40
+ attrs["billing_address"] = AgenticCommerceProtocol::Address.deserialize(attributes["billing_address"])
41
+ end
42
+
43
+ attrs["risk_signals"] = attributes["risk_signals"].map { |v| AgenticCommerceProtocol::RiskSignal.deserialize(v) }
44
+ attrs["metadata"] = attributes["metadata"]
45
+ new(attrs)
46
+ end
47
+
48
+ def serialize
49
+ out = Hash.new
50
+ out["payment_method"] = AgenticCommerceProtocol::serialize_schema_ref(@payment_method) if @payment_method
51
+ out["allowance"] = AgenticCommerceProtocol::serialize_schema_ref(@allowance) if @allowance
52
+ out["billing_address"] = AgenticCommerceProtocol::serialize_schema_ref(@billing_address) if @billing_address
53
+ out["risk_signals"] = @risk_signals.map { |v| v.serialize } if @risk_signals
54
+ out["metadata"] = AgenticCommerceProtocol::serialize_primitive(@metadata) if @metadata
55
+ out
56
+ end
57
+
58
+ # Serializes the object to a json string
59
+ # @return String
60
+ def to_json
61
+ JSON.dump(serialize)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module AgenticCommerceProtocol
6
+ class DelegatePaymentResponse
7
+ attr_accessor :id
8
+ attr_accessor :created
9
+ attr_accessor :metadata
10
+
11
+ ALL_FIELD ||= ["id", "created", "metadata"].freeze
12
+ private_constant :ALL_FIELD
13
+
14
+ def initialize(attributes = {})
15
+ unless attributes.is_a?(Hash)
16
+ fail(
17
+ ArgumentError,
18
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::DelegatePaymentResponse` new method"
19
+ )
20
+ end
21
+
22
+ attributes.each do |k, v|
23
+ unless ALL_FIELD.include?(k.to_s)
24
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::DelegatePaymentResponse")
25
+ end
26
+
27
+ instance_variable_set("@#{k}", v)
28
+ instance_variable_set("@__#{k}_is_defined", true)
29
+ end
30
+ end
31
+
32
+ def self.deserialize(attributes = {})
33
+ attributes = attributes.transform_keys(&:to_s)
34
+ attrs = Hash.new
35
+ attrs["id"] = attributes["id"]
36
+ attrs["created"] = attributes["created"]
37
+ attrs["metadata"] = attributes["metadata"]
38
+ new(attrs)
39
+ end
40
+
41
+ def serialize
42
+ out = Hash.new
43
+ out["id"] = AgenticCommerceProtocol::serialize_primitive(@id) if @id
44
+ out["created"] = AgenticCommerceProtocol::serialize_primitive(@created) if @created
45
+ out["metadata"] = AgenticCommerceProtocol::serialize_primitive(@metadata) if @metadata
46
+ out
47
+ end
48
+
49
+ # Serializes the object to a json string
50
+ # @return String
51
+ def to_json
52
+ JSON.dump(serialize)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module AgenticCommerceProtocol
6
+ class Error
7
+ attr_accessor :type
8
+ attr_accessor :code
9
+ attr_accessor :message
10
+ attr_accessor :param
11
+
12
+ ALL_FIELD ||= ["type", "code", "message", "param"].freeze
13
+ private_constant :ALL_FIELD
14
+
15
+ def initialize(attributes = {})
16
+ unless attributes.is_a?(Hash)
17
+ fail(
18
+ ArgumentError,
19
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::Error` new method"
20
+ )
21
+ end
22
+
23
+ attributes.each do |k, v|
24
+ unless ALL_FIELD.include?(k.to_s)
25
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::Error")
26
+ end
27
+
28
+ instance_variable_set("@#{k}", v)
29
+ instance_variable_set("@__#{k}_is_defined", true)
30
+ end
31
+ end
32
+
33
+ def self.deserialize(attributes = {})
34
+ attributes = attributes.transform_keys(&:to_s)
35
+ attrs = Hash.new
36
+ attrs["type"] = AgenticCommerceProtocol::ErrorType.deserialize(attributes["type"])
37
+ attrs["code"] = attributes["code"]
38
+ attrs["message"] = attributes["message"]
39
+ attrs["param"] = attributes["param"]
40
+ new(attrs)
41
+ end
42
+
43
+ def serialize
44
+ out = Hash.new
45
+ out["type"] = AgenticCommerceProtocol::serialize_schema_ref(@type) if @type
46
+ out["code"] = AgenticCommerceProtocol::serialize_primitive(@code) if @code
47
+ out["message"] = AgenticCommerceProtocol::serialize_primitive(@message) if @message
48
+ out["param"] = AgenticCommerceProtocol::serialize_primitive(@param) if @param
49
+ out
50
+ end
51
+
52
+ # Serializes the object to a json string
53
+ # @return String
54
+ def to_json
55
+ JSON.dump(serialize)
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ module AgenticCommerceProtocol
4
+ class ErrorCode
5
+ MISSING = "missing".freeze
6
+ INVALID = "invalid".freeze
7
+ OUT_OF_STOCK = "out_of_stock".freeze
8
+ PAYMENT_DECLINED = "payment_declined".freeze
9
+ REQUIRES_SIGN_IN = "requires_sign_in".freeze
10
+ REQUIRES_3DS = "requires_3ds".freeze
11
+
12
+ def self.all_vars
13
+ @all_vars ||= [MISSING, INVALID, OUT_OF_STOCK, PAYMENT_DECLINED, REQUIRES_SIGN_IN, REQUIRES_3DS].freeze
14
+ end
15
+
16
+ def initialize(value)
17
+ unless ErrorCode.all_vars.include?(value)
18
+ raise "Invalid ENUM value '#{value}' for class #ErrorCode"
19
+ end
20
+
21
+ @value = value
22
+ end
23
+
24
+ def self.deserialize(value)
25
+ return value if ErrorCode.all_vars.include?(value)
26
+ raise "Invalid ENUM value '#{value}' for class #ErrorCode"
27
+ end
28
+
29
+ def serialize
30
+ @value
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ module AgenticCommerceProtocol
4
+ class ErrorType
5
+ INVALID_REQUEST = "invalid_request".freeze
6
+ REQUEST_NOT_IDEMPOTENT = "request_not_idempotent".freeze
7
+ PROCESSING_ERROR = "processing_error".freeze
8
+ SERVICE_UNAVAILABLE = "service_unavailable".freeze
9
+
10
+ def self.all_vars
11
+ @all_vars ||= [INVALID_REQUEST, REQUEST_NOT_IDEMPOTENT, PROCESSING_ERROR, SERVICE_UNAVAILABLE].freeze
12
+ end
13
+
14
+ def initialize(value)
15
+ unless ErrorType.all_vars.include?(value)
16
+ raise "Invalid ENUM value '#{value}' for class #ErrorType"
17
+ end
18
+
19
+ @value = value
20
+ end
21
+
22
+ def self.deserialize(value)
23
+ return value if ErrorType.all_vars.include?(value)
24
+ raise "Invalid ENUM value '#{value}' for class #ErrorType"
25
+ end
26
+
27
+ def serialize
28
+ @value
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module AgenticCommerceProtocol
6
+ class EventDataOrder
7
+ attr_accessor :type
8
+ attr_accessor :checkout_session_id
9
+ attr_accessor :permalink_url
10
+ attr_accessor :status
11
+ attr_accessor :refunds
12
+
13
+ ALL_FIELD ||= ["type", "checkout_session_id", "permalink_url", "status", "refunds"].freeze
14
+ private_constant :ALL_FIELD
15
+
16
+ def initialize(attributes = {})
17
+ unless attributes.is_a?(Hash)
18
+ fail(
19
+ ArgumentError,
20
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::EventDataOrder` new method"
21
+ )
22
+ end
23
+
24
+ attributes.each do |k, v|
25
+ unless ALL_FIELD.include?(k.to_s)
26
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::EventDataOrder")
27
+ end
28
+
29
+ instance_variable_set("@#{k}", v)
30
+ instance_variable_set("@__#{k}_is_defined", true)
31
+ end
32
+ end
33
+
34
+ def self.deserialize(attributes = {})
35
+ attributes = attributes.transform_keys(&:to_s)
36
+ attrs = Hash.new
37
+ attrs["type"] = attributes["type"]
38
+ attrs["checkout_session_id"] = attributes["checkout_session_id"]
39
+ attrs["permalink_url"] = attributes["permalink_url"]
40
+ attrs["status"] = AgenticCommerceProtocol::WebhookOrderStatus.deserialize(attributes["status"])
41
+ attrs["refunds"] = attributes["refunds"].map { |v| AgenticCommerceProtocol::Refund.deserialize(v) }
42
+ new(attrs)
43
+ end
44
+
45
+ def serialize
46
+ out = Hash.new
47
+ out["type"] = AgenticCommerceProtocol::serialize_primitive(@type) if @type
48
+ if @checkout_session_id
49
+ out["checkout_session_id"] = AgenticCommerceProtocol::serialize_primitive(@checkout_session_id)
50
+ end
51
+
52
+ out["permalink_url"] = AgenticCommerceProtocol::serialize_primitive(@permalink_url) if @permalink_url
53
+ out["status"] = AgenticCommerceProtocol::serialize_schema_ref(@status) if @status
54
+ out["refunds"] = @refunds.map { |v| v.serialize } if @refunds
55
+ out
56
+ end
57
+
58
+ # Serializes the object to a json string
59
+ # @return String
60
+ def to_json
61
+ JSON.dump(serialize)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ require_relative "./fulfillment_option_digital"
6
+ require_relative "./fulfillment_option_shipping"
7
+
8
+ module AgenticCommerceProtocol
9
+ class FulfillmentOptionData
10
+ class Shipping < FulfillmentOptionShipping
11
+ end
12
+
13
+ class Digital < FulfillmentOptionDigital
14
+ end
15
+ end
16
+
17
+ class FulfillmentOption
18
+ attr_accessor :data
19
+
20
+ ALL_FIELD ||= ["data"].freeze
21
+ private_constant :ALL_FIELD
22
+ TYPE_TO_NAME = {
23
+ FulfillmentOptionData::Shipping => "shipping",
24
+ FulfillmentOptionData::Digital => "digital"
25
+ }
26
+ private_constant :TYPE_TO_NAME
27
+ NAME_TO_TYPE = TYPE_TO_NAME.invert
28
+ private_constant :NAME_TO_TYPE
29
+
30
+ def initialize(attributes = {})
31
+ unless attributes.is_a?(Hash)
32
+ fail(
33
+ ArgumentError,
34
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::FulfillmentOption` new method"
35
+ )
36
+ end
37
+
38
+ attributes.each do |k, v|
39
+ unless ALL_FIELD.include?(k.to_s)
40
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::FulfillmentOption")
41
+ end
42
+
43
+ if k == "data"
44
+ unless TYPE_TO_NAME.key?(v.class)
45
+ fail(ArgumentError, "The field #{k} can't be a `#{v.class}` expected one of #{TYPE_TO_NAME.keys}")
46
+ end
47
+
48
+ instance_variable_set("@__enum_discriminator", TYPE_TO_NAME[v.class])
49
+ end
50
+
51
+ instance_variable_set("@#{k}", v)
52
+ instance_variable_set("@__#{k}_is_defined", true)
53
+ end
54
+
55
+ if @__enum_discriminator.nil?
56
+ fail(ArgumentError, "Required data field was not set")
57
+ end
58
+ end
59
+
60
+ def self.deserialize(attributes = {})
61
+ attributes = attributes.transform_keys(&:to_s)
62
+ attrs = Hash.new
63
+ unless NAME_TO_TYPE.key?(attributes["type"])
64
+ fail(ArgumentError, "Invalid type `#{attributes["type"]}` expected on of #{NAME_TO_TYPE.keys}")
65
+ end
66
+
67
+ unless attributes.key?("data")
68
+ fail(ArgumentError, "Missing required field data")
69
+ end
70
+
71
+ attrs["data"] = NAME_TO_TYPE[attributes["type"]].deserialize(attributes["data"])
72
+ new(attrs)
73
+ end
74
+
75
+ def serialize
76
+ out = Hash.new
77
+ out["type"] = @__enum_discriminator
78
+ out["data"] = @data.serialize
79
+ out
80
+ end
81
+
82
+ # Serializes the object to a json string
83
+ # @return String
84
+ def to_json
85
+ JSON.dump(serialize)
86
+ end
87
+
88
+ end
89
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module AgenticCommerceProtocol
6
+ class FulfillmentOptionDigital
7
+ attr_accessor :id
8
+ attr_accessor :title
9
+ attr_accessor :subtitle
10
+ attr_accessor :subtotal
11
+ attr_accessor :tax
12
+ attr_accessor :total
13
+
14
+ ALL_FIELD ||= ["id", "title", "subtitle", "subtotal", "tax", "total"].freeze
15
+ private_constant :ALL_FIELD
16
+
17
+ def initialize(attributes = {})
18
+ unless attributes.is_a?(Hash)
19
+ fail(
20
+ ArgumentError,
21
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::FulfillmentOptionDigital` new method"
22
+ )
23
+ end
24
+
25
+ attributes.each do |k, v|
26
+ unless ALL_FIELD.include?(k.to_s)
27
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::FulfillmentOptionDigital")
28
+ end
29
+
30
+ instance_variable_set("@#{k}", v)
31
+ instance_variable_set("@__#{k}_is_defined", true)
32
+ end
33
+ end
34
+
35
+ def self.deserialize(attributes = {})
36
+ attributes = attributes.transform_keys(&:to_s)
37
+ attrs = Hash.new
38
+ attrs["id"] = attributes["id"]
39
+ attrs["title"] = attributes["title"]
40
+ attrs["subtitle"] = attributes["subtitle"]
41
+ attrs["subtotal"] = attributes["subtotal"]
42
+ attrs["tax"] = attributes["tax"]
43
+ attrs["total"] = attributes["total"]
44
+ new(attrs)
45
+ end
46
+
47
+ def serialize
48
+ out = Hash.new
49
+ out["id"] = AgenticCommerceProtocol::serialize_primitive(@id) if @id
50
+ out["title"] = AgenticCommerceProtocol::serialize_primitive(@title) if @title
51
+ out["subtitle"] = AgenticCommerceProtocol::serialize_primitive(@subtitle) if @subtitle
52
+ out["subtotal"] = AgenticCommerceProtocol::serialize_primitive(@subtotal) if @subtotal
53
+ out["tax"] = AgenticCommerceProtocol::serialize_primitive(@tax) if @tax
54
+ out["total"] = AgenticCommerceProtocol::serialize_primitive(@total) if @total
55
+ out
56
+ end
57
+
58
+ # Serializes the object to a json string
59
+ # @return String
60
+ def to_json
61
+ JSON.dump(serialize)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module AgenticCommerceProtocol
6
+ class FulfillmentOptionShipping
7
+ attr_accessor :id
8
+ attr_accessor :title
9
+ attr_accessor :subtitle
10
+ attr_accessor :carrier
11
+ attr_accessor :earliest_delivery_time
12
+ attr_accessor :latest_delivery_time
13
+ attr_accessor :subtotal
14
+ attr_accessor :tax
15
+ attr_accessor :total
16
+
17
+ ALL_FIELD ||= [
18
+ "id",
19
+ "title",
20
+ "subtitle",
21
+ "carrier",
22
+ "earliest_delivery_time",
23
+ "latest_delivery_time",
24
+ "subtotal",
25
+ "tax",
26
+ "total"
27
+ ].freeze
28
+ private_constant :ALL_FIELD
29
+
30
+ def initialize(attributes = {})
31
+ unless attributes.is_a?(Hash)
32
+ fail(
33
+ ArgumentError,
34
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::FulfillmentOptionShipping` new method"
35
+ )
36
+ end
37
+
38
+ attributes.each do |k, v|
39
+ unless ALL_FIELD.include?(k.to_s)
40
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::FulfillmentOptionShipping")
41
+ end
42
+
43
+ instance_variable_set("@#{k}", v)
44
+ instance_variable_set("@__#{k}_is_defined", true)
45
+ end
46
+ end
47
+
48
+ def self.deserialize(attributes = {})
49
+ attributes = attributes.transform_keys(&:to_s)
50
+ attrs = Hash.new
51
+ attrs["id"] = attributes["id"]
52
+ attrs["title"] = attributes["title"]
53
+ attrs["subtitle"] = attributes["subtitle"]
54
+ attrs["carrier"] = attributes["carrier"]
55
+ attrs["earliest_delivery_time"] = attributes["earliest_delivery_time"]
56
+ attrs["latest_delivery_time"] = attributes["latest_delivery_time"]
57
+ attrs["subtotal"] = attributes["subtotal"]
58
+ attrs["tax"] = attributes["tax"]
59
+ attrs["total"] = attributes["total"]
60
+ new(attrs)
61
+ end
62
+
63
+ def serialize
64
+ out = Hash.new
65
+ out["id"] = AgenticCommerceProtocol::serialize_primitive(@id) if @id
66
+ out["title"] = AgenticCommerceProtocol::serialize_primitive(@title) if @title
67
+ out["subtitle"] = AgenticCommerceProtocol::serialize_primitive(@subtitle) if @subtitle
68
+ out["carrier"] = AgenticCommerceProtocol::serialize_primitive(@carrier) if @carrier
69
+ if @earliest_delivery_time
70
+ out["earliest_delivery_time"] = AgenticCommerceProtocol::serialize_primitive(@earliest_delivery_time)
71
+ end
72
+
73
+ if @latest_delivery_time
74
+ out["latest_delivery_time"] = AgenticCommerceProtocol::serialize_primitive(@latest_delivery_time)
75
+ end
76
+
77
+ out["subtotal"] = AgenticCommerceProtocol::serialize_primitive(@subtotal) if @subtotal
78
+ out["tax"] = AgenticCommerceProtocol::serialize_primitive(@tax) if @tax
79
+ out["total"] = AgenticCommerceProtocol::serialize_primitive(@total) if @total
80
+ out
81
+ end
82
+
83
+ # Serializes the object to a json string
84
+ # @return String
85
+ def to_json
86
+ JSON.dump(serialize)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ # This file is @generated
3
+ require "json"
4
+
5
+ module AgenticCommerceProtocol
6
+ class Item
7
+ attr_accessor :id
8
+ attr_accessor :quantity
9
+
10
+ ALL_FIELD ||= ["id", "quantity"].freeze
11
+ private_constant :ALL_FIELD
12
+
13
+ def initialize(attributes = {})
14
+ unless attributes.is_a?(Hash)
15
+ fail(
16
+ ArgumentError,
17
+ "The input argument (attributes) must be a hash in `AgenticCommerceProtocol::Item` new method"
18
+ )
19
+ end
20
+
21
+ attributes.each do |k, v|
22
+ unless ALL_FIELD.include?(k.to_s)
23
+ fail(ArgumentError, "The field #{k} is not part of AgenticCommerceProtocol::Item")
24
+ end
25
+
26
+ instance_variable_set("@#{k}", v)
27
+ instance_variable_set("@__#{k}_is_defined", true)
28
+ end
29
+ end
30
+
31
+ def self.deserialize(attributes = {})
32
+ attributes = attributes.transform_keys(&:to_s)
33
+ attrs = Hash.new
34
+ attrs["id"] = attributes["id"]
35
+ attrs["quantity"] = attributes["quantity"]
36
+ new(attrs)
37
+ end
38
+
39
+ def serialize
40
+ out = Hash.new
41
+ out["id"] = AgenticCommerceProtocol::serialize_primitive(@id) if @id
42
+ out["quantity"] = AgenticCommerceProtocol::serialize_primitive(@quantity) if @quantity
43
+ out
44
+ end
45
+
46
+ # Serializes the object to a json string
47
+ # @return String
48
+ def to_json
49
+ JSON.dump(serialize)
50
+ end
51
+ end
52
+ end