Class: Tamara::Orders::Create

Inherits:
ApplicationService show all
Includes:
JsonSchemas::Orders::Create
Defined in:
lib/tamara/api/orders/create.rb

Constant Summary

Constants included from JsonSchemas::Orders::Create

JsonSchemas::Orders::Create::LOCALES, JsonSchemas::Orders::Create::PAYMENT_TYPES, JsonSchemas::Orders::Create::REQUIRED_KEYS

Constants included from JsonSchemas::Validator

JsonSchemas::Validator::ERROR_MESSAGES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JsonSchemas::Validator

#validate_params!

Methods included from JsonSchemas::CheckoutOptionalKeys

#checkout_optional_keys

Methods inherited from ApplicationService

#call, #initialize

Methods included from Request

#api_token, #error_message, #handle_response_error, #headers, #parsed_response, #response_body, #response_status

Constructor Details

This class inherits a constructor from Tamara::ApplicationService

Class Method Details

.call(order_reference_id:, country_code:, description:, total_amount:, shipping_amount:, tax_amount:, consumer:, items:, merchant_url:, shipping_address:, payment_type: "PAY_BY_INSTALMENTS", installments: 3, order_number: nil, discount: nil, billing_address: nil, platform: "", is_mobile: false, locale: "ar_SA", risk_assessment: nil, additional_data: nil, expires_in_minutes: 30, opts: {}) ⇒ Object

rubocop:disable Layout/LineLength



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tamara/api/orders/create.rb', line 7

def self.call(order_reference_id:, country_code:, description:, total_amount:, shipping_amount:, tax_amount:, consumer:, items:, merchant_url:, shipping_address:, payment_type: "PAY_BY_INSTALMENTS", installments: 3, order_number: nil, discount: nil, billing_address: nil, platform: "", is_mobile: false, locale: "ar_SA", risk_assessment: nil, additional_data: nil, expires_in_minutes: 30, opts: {})
  new(order_reference_id: order_reference_id,
      country_code: country_code,
      description: description,
      total_amount: total_amount,
      shipping_amount: shipping_amount,
      tax_amount: tax_amount,
      consumer: consumer,
      items: items,
      merchant_url: merchant_url,
      shipping_address: shipping_address,
      payment_type: payment_type,
      installments: installments,
      order_number: order_number,
      discount: discount,
      billing_address: billing_address,
      platform: platform,
      is_mobile: is_mobile,
      locale: locale,
      risk_assessment: risk_assessment,
      additional_data: additional_data,
      expires_in_minutes: expires_in_minutes,
      opts: opts).call
end

Instance Method Details

#call_apiObject

rubocop:enable Layout/LineLength



33
34
35
# File 'lib/tamara/api/orders/create.rb', line 33

def call_api
  ::Faraday.post(url, api_params.to_json, headers)
end

#urlObject



37
38
39
# File 'lib/tamara/api/orders/create.rb', line 37

def url
  Tamara.checkout_uri
end