Class: Workarea::Yotpo::Gateway

Inherits:
Object
  • Object
show all
Includes:
Authentication
Defined in:
lib/workarea/yotpo/gateway.rb

Defined Under Namespace

Classes: YotpoGatewayError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#token

Constructor Details

#initialize(options = {}) ⇒ Gateway

Returns a new instance of Gateway.



9
10
11
12
# File 'lib/workarea/yotpo/gateway.rb', line 9

def initialize(options = {})
  requires!(options, :app_key, :secret_key)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/workarea/yotpo/gateway.rb', line 7

def options
  @options
end

Instance Method Details

#create_order(order_details) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/workarea/yotpo/gateway.rb', line 14

def create_order(order_details)
  auth_creds = {
    utoken: token,
    app_key: client_id
  }

  body = order_details.merge(auth_creds).to_json

  response = connection.post do |req|
    req.url "apps/#{client_id}/purchases/"
    req.body = body
  end

  Response.new(response)
end