Class: NewStoreApi::CartController
- Inherits:
-
BaseController
- Object
- BaseController
- NewStoreApi::CartController
- Defined in:
- lib/new_store_api/controllers/cart_controller.rb
Overview
CartController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#add_payment_by_reference(cart_id, payment_reference) ⇒ void
🚧 BETA: This endpoint is in beta and may change.
- #create_add_on_line_item(cart_id, line_item_id, body) ⇒ AddItemResponseBody
Create an add-on for a line item on a cart description here.
- #create_cart(body) ⇒ void
Creates a new empty cart.
- #create_line_item(cart_id, body) ⇒ AddItemResponseBody
Add a line item to a cart description here.
- #destroy_line_item(cart_id, line_item_id) ⇒ RemoveItemResponseBody
Removes a line item and all its add-ons from the cart.
- #list_cart_changes(cart_id) ⇒ ChangesResponseBody
Returns a list of changes for a cart.
- #list_carts(returned_order_id: nil) ⇒ HttpResponseBody
Returns a list of carts based on a search criteria.
- #show_cart(cart_id) ⇒ CartResource
Returns a cart by its ID.
- #update_cart(cart_id, body) ⇒ void
Changes a cart.
- #update_line_item(cart_id, line_item_id, body) ⇒ ChangeItemResponseBody
Updates cart line item details description here.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from NewStoreApi::BaseController
Instance Method Details
#add_payment_by_reference(cart_id, payment_reference) ⇒ void
This method returns an undefined value.
🚧 BETA: This endpoint is in beta and may change.Adds a payment for a cart by using a reference.
See API Lifecycle Documentation for details.218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
# File 'lib/new_store_api/controllers/cart_controller.rb', line 218 def add_payment_by_reference(cart_id, payment_reference) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/checkout/carts/{cartId}/payment-references/{paymentReference}', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .template_param(new_parameter(payment_reference, key: 'paymentReference') .should_encode(true)) .auth(Single.new('oauth'))) .response(new_response_handler .is_response_void(true)) .execute end
#create_add_on_line_item(cart_id, line_item_id, body) ⇒ AddItemResponseBody
Create an add-on for a line item on a cart description here
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
# File 'lib/new_store_api/controllers/cart_controller.rb', line 183 def create_add_on_line_item(cart_id, line_item_id, body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/checkout/carts/{cartId}/items/{lineItemId}/add-ons', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .template_param(new_parameter(line_item_id, key: 'lineItemId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(AddItemResponseBody.method(:from_hash))) .execute end
#create_cart(body) ⇒ void
This method returns an undefined value.
Creates a new empty cart. description here
31 32 33 34 35 36 37 38 39 40 41 42 43
# File 'lib/new_store_api/controllers/cart_controller.rb', line 31 def create_cart(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/checkout/carts', Server::API) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('oauth'))) .response(new_response_handler .is_response_void(true)) .execute end
#create_line_item(cart_id, body) ⇒ AddItemResponseBody
Add a line item to a cart description here
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
# File 'lib/new_store_api/controllers/cart_controller.rb', line 108 def create_line_item(cart_id, body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/checkout/carts/{cartId}/items', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(AddItemResponseBody.method(:from_hash))) .execute end
#destroy_line_item(cart_id, line_item_id) ⇒ RemoveItemResponseBody
Removes a line item and all its add-ons from the cart.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
# File 'lib/new_store_api/controllers/cart_controller.rb', line 131 def destroy_line_item(cart_id, line_item_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/checkout/carts/{cartId}/items/{lineItemId}', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .template_param(new_parameter(line_item_id, key: 'lineItemId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(RemoveItemResponseBody.method(:from_hash))) .execute end
#list_cart_changes(cart_id) ⇒ ChangesResponseBody
Returns a list of changes for a cart
88 89 90 91 92 93 94 95 96 97 98 99 100 101
# File 'lib/new_store_api/controllers/cart_controller.rb', line 88 def list_cart_changes(cart_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/checkout/carts/{cartId}/changes', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ChangesResponseBody.method(:from_hash))) .execute end
#list_carts(returned_order_id: nil) ⇒ HttpResponseBody
Returns a list of carts based on a search criteria. or already returned
13 14 15 16 17 18 19 20 21 22 23 24 25
# File 'lib/new_store_api/controllers/cart_controller.rb', line 13 def list_carts(returned_order_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/checkout/carts', Server::API) .query_param(new_parameter(returned_order_id, key: 'returned_order_id')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(HttpResponseBody.method(:from_hash))) .execute end
#show_cart(cart_id) ⇒ CartResource
Returns a cart by its ID.
48 49 50 51 52 53 54 55 56 57 58 59 60 61
# File 'lib/new_store_api/controllers/cart_controller.rb', line 48 def show_cart(cart_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/checkout/carts/{cartId}', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CartResource.method(:from_hash))) .execute end
#update_cart(cart_id, body) ⇒ void
This method returns an undefined value.
Changes a cart. description here
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
# File 'lib/new_store_api/controllers/cart_controller.rb', line 68 def update_cart(cart_id, body) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/checkout/carts/{cartId}', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('oauth'))) .response(new_response_handler .is_response_void(true)) .execute end
#update_line_item(cart_id, line_item_id, body) ⇒ ChangeItemResponseBody
Updates cart line item details description here
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
# File 'lib/new_store_api/controllers/cart_controller.rb', line 155 def update_line_item(cart_id, line_item_id, body) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/checkout/carts/{cartId}/items/{lineItemId}', Server::API) .template_param(new_parameter(cart_id, key: 'cartId') .should_encode(true)) .template_param(new_parameter(line_item_id, key: 'lineItemId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ChangeItemResponseBody.method(:from_hash))) .execute end
- #create_add_on_line_item(cart_id, line_item_id, body) ⇒ AddItemResponseBody