Module: Epages::REST::Carts
- Includes:
- Utils
- Included in:
- API
- Defined in:
- lib/epages/rest/carts.rb
Overview
Instance Method Summary
collapse
Methods included from Utils
#epages_id, #format_date, #format_dates_options, #parse_legal_info, #parse_links, #parse_price_info, #parse_product_lowest_price, #parse_product_variations, #parse_suggestions_to_products, #parse_variation_object, #parse_variations, #perform_delete_request, #perform_delete_with_object, #perform_get_request, #perform_get_with_key_and_objects, #perform_get_with_object, #perform_get_with_objects, #perform_multipart_post_with_objects, #perform_patch_with_object, #perform_post_request, #perform_post_with_key_and_objects, #perform_post_with_object, #perform_post_with_objects, #perform_put_request, #perform_put_with_object, #perform_request, #perform_request_with_key_and_objects, #perform_request_with_object, #perform_request_with_objects, #process_thread
Instance Method Details
#apply_coupon(cart, data = {}) ⇒ Object
23
24
25
26
|
# File 'lib/epages/rest/carts.rb', line 23
def apply_coupon(cart, data = {})
id = epages_id(cart)
perform_post_with_object("/carts/#{id}/coupon", data, Epages::Cart)
end
|
#cart(cart) ⇒ Object
17
18
19
20
|
# File 'lib/epages/rest/carts.rb', line 17
def cart(cart)
id = epages_id(cart)
perform_get_with_object("/carts/#{id}", {}, Epages::Cart)
end
|
#cart_line_item(cart, product, quantity = 1) ⇒ Object
Also known as:
add_product_to_cart
42
43
44
45
46
|
# File 'lib/epages/rest/carts.rb', line 42
def cart_line_item(cart, product, quantity = 1)
id = epages_id(cart)
lineitem = product.is_a?(Epages::Product) ? product.to_line_item(quantity) : product
perform_post_with_object("/carts/#{id}/line-items", lineitem, Epages::Cart)
end
|
#create_cart(data = {}) ⇒ Object
11
12
13
14
|
# File 'lib/epages/rest/carts.rb', line 11
def create_cart(data = {})
default = {currency: 'EUR', taxType: 'GROSS', locale: 'en_GB', lineItems: []}
perform_post_with_object('/carts', default.merge(camelize_keys(data)), Epages::Cart)
end
|
#delete_cart_billing_address(cart) ⇒ Object
71
72
73
74
|
# File 'lib/epages/rest/carts.rb', line 71
def delete_cart_billing_address(cart)
id = epages_id(cart)
perform_delete_with_object("/carts/#{id}/billing-address", {}, Epages::Cart)
end
|
#delete_cart_line_item(cart, lineitem) ⇒ Object
57
58
59
60
61
|
# File 'lib/epages/rest/carts.rb', line 57
def delete_cart_line_item(cart, lineitem)
id = epages_id(cart)
lineitem = lineitem.line_item_id if lineitem.is_a?(Epages::ProductLineItem)
perform_delete_with_object("/carts/#{id}/line-items/#{lineitem}", {}, Epages::Cart)
end
|
#delete_cart_shipping_address(cart) ⇒ Object
84
85
86
87
|
# File 'lib/epages/rest/carts.rb', line 84
def delete_cart_shipping_address(cart)
id = epages_id(cart)
perform_delete_with_object("/carts/#{id}/shipping-address", {}, Epages::Cart)
end
|
#delete_coupon(cart, coupon_line_item_id) ⇒ Object
30
31
32
33
|
# File 'lib/epages/rest/carts.rb', line 30
def delete_coupon(cart, coupon_line_item_id)
id = epages_id(cart)
perform_delete_with_object("/carts/#{id}/coupon/#{coupon_line_item_id}", {}, Epages::Cart)
end
|
#order_cart(cart) ⇒ Object
36
37
38
39
|
# File 'lib/epages/rest/carts.rb', line 36
def order_cart(cart)
id = epages_id(cart)
perform_post_with_object("/carts/#{id}/order", {}, Epages::Order)
end
|
#update_cart_billing_address(cart, address) ⇒ Object
64
65
66
67
68
|
# File 'lib/epages/rest/carts.rb', line 64
def update_cart_billing_address(cart, address)
id = epages_id(cart)
address = address.to_json if address.is_a?(Epages::Address)
perform_put_with_object("/carts/#{id}/billing-address", address, Epages::Cart)
end
|
#update_cart_line_item(cart, lineitem, options) ⇒ Object
50
51
52
53
54
|
# File 'lib/epages/rest/carts.rb', line 50
def update_cart_line_item(cart, lineitem, options)
id = epages_id(cart)
lineitem = lineitem.line_item_id if lineitem.is_a?(Epages::ProductLineItem)
perform_put_with_object("/carts/#{id}/line-items/#{lineitem}", options, Epages::Cart)
end
|
#update_cart_shipping_address(cart, address) ⇒ Object
77
78
79
80
81
|
# File 'lib/epages/rest/carts.rb', line 77
def update_cart_shipping_address(cart, address)
id = epages_id(cart)
address = address.to_json if address.is_a?(Epages::Address)
perform_put_with_object("/carts/#{id}/shipping-address", address, Epages::Cart)
end
|