Class: Workarea::GlobalE::Merchant::ResponseInfo

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/global_e/merchant/response_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order: nil, message: nil, success: true) ⇒ ResponseInfo

Returns a new instance of ResponseInfo.



11
12
13
14
15
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 11

def initialize(order: nil, message: nil, success: true)
  @order = order
  @message = message
  @success = success
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



5
6
7
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 5

def order
  @order
end

Class Method Details

.error(message:, order: nil) ⇒ Object



7
8
9
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 7

def self.error(message:, order: nil)
  new(success: false, message: message, order: order)
end

Instance Method Details

#as_json(*args) ⇒ Object



31
32
33
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 31

def as_json(*args)
  to_h
end

#descriptionString

Optional response description. In case of an error, this property indicates the error message description.

Returns:

  • (String)


110
111
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 110

def description
end

#error_codeString

Error code to be returned when an error occurs.

Returns:

  • (String)


93
94
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 93

def error_code
end

#internal_order_idString

Order unique identifier on the Merchant’s site (optional in case of error, failure or if the action is not related to a specific order)

Returns:

  • (String)


41
42
43
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 41

def internal_order_id
  order&.id
end

#messageString

Optional response message. In case of an error, this property indicates the error message text.

Returns:

  • (String)


101
102
103
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 101

def message
  @message
end

#order_idString

Order identifier on the Merchant’s site used for display and reporting purposes only. Unlike InternalOrderId, this identifier is not necessarily unique over time, as the Merchant’s site may potentially reuse it (for example after deleting the old order having the same OrderId).

Returns:

  • (String)


53
54
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 53

def order_id
end

#payment_amountString

The total payment amount in PaymentCurrency charged for the order (if payment was processed in the respective API method call).

Returns:

  • (String)


78
79
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 78

def payment_amount
end

#payment_currency_codeString

3-char ISO currency code for the order (if payment was processed in the respective API method call).

Returns:

  • (String)


70
71
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 70

def payment_currency_code
end

#status_codeString

Code denoting the order status on the Merchant’s site (to be mapped on Global-e side). (optional in case of error or failure)

Returns:

  • (String)


62
63
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 62

def status_code
end

#successBoolean

Indicates if the call has succeeded. FALSE denotes an error or failure.

Returns:

  • (Boolean)


85
86
87
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 85

def success
  @success
end

#to_hObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/workarea/global_e/merchant/response_info.rb', line 17

def to_h
  {
    InternalOrderId: internal_order_id,
    OrderId: order_id,
    StatusCode: status_code,
    PaymentCurrencyCode: payment_currency_code,
    PaymentAmount: payment_amount,
    Success: success,
    ErrorCode: error_code,
    Message: message,
    Description: description
  }
end