Class: Workarea::GlobalE::Merchant::Discount

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Discount

Returns a new instance of Discount.



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

def initialize(hash)
  @hash = hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

Instance Method Details

#coupon_codeString

Merchant’s coupon code used for this discount (applicable to coupon-based discounts only)

Returns:

  • (String)


71
72
73
# File 'app/services/workarea/global_e/merchant/discount.rb', line 71

def coupon_code
  hash["CouponCode"]
end

#descriptionString

Discount textual description

Returns:

  • (String)


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

def description
  hash["Description"]
end

#discount_codeString

Discount code originally specified in Discount.DiscountCode property of the respective discount in SendCart method for the cart converted to this order on Global-e.

Returns:

  • (String)


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

def discount_code
  hash["DiscountCode"]
end

#discount_typeInteger

Discount type (“Cart”, “Shipping”, etc.), as defined in | DiscountType Option Value | Name | Description | | 1 | Cart Discount | Discount related to volume, amount, coupon or another promotion value. | | 2 | Shipping Discount | Discount aimed to sponsor international shipping. | | 3 | Loyalty points discount | Discount applied against the Merchant’s loyalty points to be spent for this purchase. | | 4 | Duties discount | Discount aimed to sponsor taxes & duties pre- paid by the end customer in Global-e checkout. | | 5 | Checkout Loyalty Points Discount | Discount applied against the Merchant’s loyalty points in Global-e checkout. | | 6 | Payment Charge | Discount aimed to sponsor “Cash on Delivery” fee. |

Returns:

  • (Integer)


117
118
119
# File 'app/services/workarea/global_e/merchant/discount.rb', line 117

def discount_type
  hash["DiscountType"]
end

#international_priceFloat

Discount value in end customer’s currency (specified in InternationalDetails.CurrencyCode property for the respective Merchant.Order), after applying country coefficient, FX conversion and IncludeVAT handling.

Returns:

  • (Float)


54
55
56
# File 'app/services/workarea/global_e/merchant/discount.rb', line 54

def international_price
  hash["InternationalPrice"]
end

#local_vat_rateFloat

VAT rate that would be applied to this discount if the order was placed by the local customer. This value must be specified if UseCountryVAT for the current Country is TRUE and therefore VATRate property actually denotes the VAT for the target country.

Returns:

  • (Float)


43
44
45
# File 'app/services/workarea/global_e/merchant/discount.rb', line 43

def local_vat_rate
  hash["LocalVATRate"]
end

#loyalty_voucher_codeString

Loyalty Voucher code originally specified in Discount.LoyaltyVoucherCode property of the respective discount in SendCart method for the cart converted to this order on Global-e.

Returns:

  • (String)


102
103
104
# File 'app/services/workarea/global_e/merchant/discount.rb', line 102

def loyalty_voucher_code
  hash["LoyaltyVoucherCode"]
end

#nameString

Discount Name

Returns:

  • (String)


15
16
17
# File 'app/services/workarea/global_e/merchant/discount.rb', line 15

def name
  hash["Name"]
end

#priceFloat

Discount value in currency defined in CurrencyCode property of the respective Merchant.Order object for the order being submitted to the Merchant.

Returns:

  • (Float)


24
25
26
# File 'app/services/workarea/global_e/merchant/discount.rb', line 24

def price
  hash["Price"]
end

#product_cart_item_idString[

Identifier of the product cart item related to this discount on the Merchant’s site originally specified in Discount.ProductCartItemId property of the respective discount in SendCart method for the cart converted to this order on Global-e.

Returns:

  • (String[)

    String[



82
83
84
# File 'app/services/workarea/global_e/merchant/discount.rb', line 82

def product_cart_item_id
  hash["ProductCartItemId"]
end

#shipping?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'app/services/workarea/global_e/merchant/discount.rb', line 121

def shipping?
  discount_type == 2
end

#vat_rateFloat

VAT rate applied to this discount

Returns:

  • (Float)


32
33
34
# File 'app/services/workarea/global_e/merchant/discount.rb', line 32

def vat_rate
  hash["VATRate"]
end