Class: NewStoreApi::TaxTransactionsController
- Inherits:
-
BaseController
- Object
- BaseController
- NewStoreApi::TaxTransactionsController
- Defined in:
- lib/new_store_api/controllers/tax_transactions_controller.rb
Overview
TaxTransactionsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_tax_transaction(body, store_id: nil) ⇒ EnrichedTransactionDto
Creates a tax transaction by calculating the total amounts of cart items using the configured tax strategy.
-
#create_tax_transaction_preview(body, store_id: nil) ⇒ EnrichedTransactionDto
Creates a preview tax transaction by calculating the total amounts of cart items using the configured tax strategy, without storing the transaction.
-
#show_order_tax_transaction(order_id, store_id: nil) ⇒ EnrichedTransactionDto
Get tax transaction for the given order identifier.
-
#show_return_tax_transaction(order_id, return_id, store_id: nil) ⇒ EnrichedTransactionDto
Get tax transaction for the given return and order identifiers.
-
#update_order_tax_transaction(order_id, body, store_id: nil) ⇒ EnrichedTransactionDto
Update tax transaction for the given order identifier.
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
#create_tax_transaction(body, store_id: nil) ⇒ EnrichedTransactionDto
Creates a tax transaction by calculating the total amounts of cart items using the configured tax strategy. here
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/new_store_api/controllers/tax_transactions_controller.rb', line 40 def create_tax_transaction(body, store_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/taxes/transactions', Server::API) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter(store_id, key: 'store-id')) .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(EnrichedTransactionDto.method(:from_hash))) .execute end |
#create_tax_transaction_preview(body, store_id: nil) ⇒ EnrichedTransactionDto
Creates a preview tax transaction by calculating the total amounts of cart items using the configured tax strategy, without storing the transaction. Intended to be used for testing and validation purposes. here
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/new_store_api/controllers/tax_transactions_controller.rb', line 16 def create_tax_transaction_preview(body, store_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/taxes/previews/transactions', Server::API) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter(store_id, key: 'store-id')) .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(EnrichedTransactionDto.method(:from_hash))) .execute end |
#show_order_tax_transaction(order_id, store_id: nil) ⇒ EnrichedTransactionDto
Get tax transaction for the given order identifier.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/new_store_api/controllers/tax_transactions_controller.rb', line 62 def show_order_tax_transaction(order_id, store_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/taxes/transactions/{orderId}', Server::API) .template_param(new_parameter(order_id, key: 'orderId') .should_encode(true)) .header_param(new_parameter(store_id, key: 'store-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(EnrichedTransactionDto.method(:from_hash))) .execute end |
#show_return_tax_transaction(order_id, return_id, store_id: nil) ⇒ EnrichedTransactionDto
Get tax transaction for the given return and order identifiers.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/new_store_api/controllers/tax_transactions_controller.rb', line 111 def show_return_tax_transaction(order_id, return_id, store_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/taxes/transactions/{orderId}/returns/{returnId}', Server::API) .template_param(new_parameter(order_id, key: 'orderId') .should_encode(true)) .template_param(new_parameter(return_id, key: 'returnId') .should_encode(true)) .header_param(new_parameter(store_id, key: 'store-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(EnrichedTransactionDto.method(:from_hash))) .execute end |
#update_order_tax_transaction(order_id, body, store_id: nil) ⇒ EnrichedTransactionDto
Update tax transaction for the given order identifier. description here
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/new_store_api/controllers/tax_transactions_controller.rb', line 85 def update_order_tax_transaction(order_id, body, store_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/taxes/transactions/{orderId}', Server::API) .template_param(new_parameter(order_id, key: 'orderId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter(store_id, key: 'store-id')) .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(EnrichedTransactionDto.method(:from_hash))) .execute end |