Class: UnivapayClientSdk::CustomsDeclarationWebhookData

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb

Overview

Customs declaration payload delivered in customs_declaration_finished webhooks. Platform-level deliveries may include platform_id and updated_on.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id: SKIP, charge_id: SKIP, merchant_id: SKIP, store_id: SKIP, platform_id: SKIP, mode: SKIP, gateway: SKIP, declaration: SKIP, declaration_result: SKIP, status: SKIP, error: SKIP, created_on: SKIP, updated_on: SKIP, additional_properties: nil) ⇒ CustomsDeclarationWebhookData

Returns a new instance of CustomsDeclarationWebhookData.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 116

def initialize(id: SKIP, charge_id: SKIP, merchant_id: SKIP, store_id: SKIP,
               platform_id: SKIP, mode: SKIP, gateway: SKIP,
               declaration: SKIP, declaration_result: SKIP, status: SKIP,
               error: SKIP, created_on: SKIP, updated_on: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id unless id == SKIP
  @charge_id = charge_id unless charge_id == SKIP
  @merchant_id = merchant_id unless merchant_id == SKIP
  @store_id = store_id unless store_id == SKIP
  @platform_id = platform_id unless platform_id == SKIP
  @mode = mode unless mode == SKIP
  @gateway = gateway unless gateway == SKIP
  @declaration = declaration unless declaration == SKIP
  @declaration_result = declaration_result unless declaration_result == SKIP
  @status = status unless status == SKIP
  @error = error unless error == SKIP
  @created_on = created_on unless created_on == SKIP
  @updated_on = updated_on unless updated_on == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#charge_idUUID | String

Charge identifier associated with the declaration.

Returns:

  • (UUID | String)


21
22
23
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 21

def charge_id
  @charge_id
end

#created_onDateTime

Timestamp when the declaration was created.

Returns:

  • (DateTime)


61
62
63
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 61

def created_on
  @created_on
end

#declarationCustomsDeclarationWebhookDeclaration

WeChat customs declaration payload returned by the backend formatter.



45
46
47
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 45

def declaration
  @declaration
end

#declaration_resultCustomsDeclarationWebhookResult

Result payload returned by the customs declaration formatter.



49
50
51
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 49

def declaration_result
  @declaration_result
end

#errorCustomsDeclarationWebhookError

Error payload returned when customs declaration processing fails.



57
58
59
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 57

def error
  @error
end

#gatewayString

Gateway that processed the declaration.

Returns:

  • (String)


41
42
43
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 41

def gateway
  @gateway
end

#idUUID | String

Customs declaration identifier.

Returns:

  • (UUID | String)


17
18
19
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 17

def id
  @id
end

#merchant_idUUID | String

Merchant identifier.

Returns:

  • (UUID | String)


25
26
27
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 25

def merchant_id
  @merchant_id
end

#modeString

Processing mode.

Returns:

  • (String)


37
38
39
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 37

def mode
  @mode
end

#platform_idUUID | String

Platform identifier, included on platform-level deliveries.

Returns:

  • (UUID | String)


33
34
35
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 33

def platform_id
  @platform_id
end

#statusCustomsDeclarationWebhookStatus

Customs declaration status returned by the backend.



53
54
55
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 53

def status
  @status
end

#store_idUUID | String

Store identifier.

Returns:

  • (UUID | String)


29
30
31
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 29

def store_id
  @store_id
end

#updated_onDateTime

Timestamp when the declaration was last updated, included on platform-level deliveries.

Returns:

  • (DateTime)


66
67
68
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 66

def updated_on
  @updated_on
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 141

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  charge_id = hash.key?('charge_id') ? hash['charge_id'] : SKIP
  merchant_id = hash.key?('merchant_id') ? hash['merchant_id'] : SKIP
  store_id = hash.key?('store_id') ? hash['store_id'] : SKIP
  platform_id = hash.key?('platform_id') ? hash['platform_id'] : SKIP
  mode = hash.key?('mode') ? hash['mode'] : SKIP
  gateway = hash.key?('gateway') ? hash['gateway'] : SKIP
  declaration = CustomsDeclarationWebhookDeclaration.from_hash(hash['declaration']) if
    hash['declaration']
  declaration_result = CustomsDeclarationWebhookResult.from_hash(hash['declaration_result']) if
    hash['declaration_result']
  status = hash.key?('status') ? hash['status'] : SKIP
  error = CustomsDeclarationWebhookError.from_hash(hash['error']) if hash['error']
  created_on = if hash.key?('created_on')
                 (DateTimeHelper.from_rfc3339(hash['created_on']) if hash['created_on'])
               else
                 SKIP
               end
  updated_on = if hash.key?('updated_on')
                 (DateTimeHelper.from_rfc3339(hash['updated_on']) if hash['updated_on'])
               else
                 SKIP
               end

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CustomsDeclarationWebhookData.new(id: id,
                                    charge_id: charge_id,
                                    merchant_id: merchant_id,
                                    store_id: store_id,
                                    platform_id: platform_id,
                                    mode: mode,
                                    gateway: gateway,
                                    declaration: declaration,
                                    declaration_result: declaration_result,
                                    status: status,
                                    error: error,
                                    created_on: created_on,
                                    updated_on: updated_on,
                                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 69

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['charge_id'] = 'charge_id'
  @_hash['merchant_id'] = 'merchant_id'
  @_hash['store_id'] = 'store_id'
  @_hash['platform_id'] = 'platform_id'
  @_hash['mode'] = 'mode'
  @_hash['gateway'] = 'gateway'
  @_hash['declaration'] = 'declaration'
  @_hash['declaration_result'] = 'declaration_result'
  @_hash['status'] = 'status'
  @_hash['error'] = 'error'
  @_hash['created_on'] = 'created_on'
  @_hash['updated_on'] = 'updated_on'
  @_hash
end

.nullablesObject

An array for nullable fields



107
108
109
110
111
112
113
114
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 107

def self.nullables
  %w[
    platform_id
    declaration_result
    error
    updated_on
  ]
end

.optionalsObject

An array for optional fields



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 88

def self.optionals
  %w[
    id
    charge_id
    merchant_id
    store_id
    platform_id
    mode
    gateway
    declaration
    declaration_result
    status
    error
    created_on
    updated_on
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



203
204
205
206
207
208
209
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 203

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



222
223
224
225
226
227
228
229
230
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 222

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, charge_id: #{@charge_id.inspect}, merchant_id:"\
  " #{@merchant_id.inspect}, store_id: #{@store_id.inspect}, platform_id:"\
  " #{@platform_id.inspect}, mode: #{@mode.inspect}, gateway: #{@gateway.inspect},"\
  " declaration: #{@declaration.inspect}, declaration_result: #{@declaration_result.inspect},"\
  " status: #{@status.inspect}, error: #{@error.inspect}, created_on: #{@created_on.inspect},"\
  " updated_on: #{@updated_on.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_onObject



193
194
195
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 193

def to_custom_created_on
  DateTimeHelper.to_rfc3339(created_on)
end

#to_custom_updated_onObject



197
198
199
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 197

def to_custom_updated_on
  DateTimeHelper.to_rfc3339(updated_on)
end

#to_sObject

Provides a human-readable string representation of the object.



212
213
214
215
216
217
218
219
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb', line 212

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, charge_id: #{@charge_id}, merchant_id: #{@merchant_id},"\
  " store_id: #{@store_id}, platform_id: #{@platform_id}, mode: #{@mode}, gateway:"\
  " #{@gateway}, declaration: #{@declaration}, declaration_result: #{@declaration_result},"\
  " status: #{@status}, error: #{@error}, created_on: #{@created_on}, updated_on:"\
  " #{@updated_on}, additional_properties: #{@additional_properties}>"
end