Class: SekoEcomAPI::OmniReturnsClient

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/seko_ecom_api/clients/omni_returns_client.rb

Constant Summary collapse

BASE_URL =
'https://www.omniparcelreturns.com/index.php/api/'.freeze
TEST_BASE_URL =
'https://test.omniparcelreturns.com/index.php/api/'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Client

#parse_params, #post_request

Constructor Details

#initialize(access_key:, adapter: :http, test: false, conn_opts: {}) ⇒ OmniReturnsClient

Returns a new instance of OmniReturnsClient.



15
16
17
18
19
20
# File 'lib/seko_ecom_api/clients/omni_returns_client.rb', line 15

def initialize(access_key:, adapter: :http, test: false, conn_opts: {})
  @access_key = access_key
  @adapter = adapter
  @test = test
  @conn_opts = conn_opts
end

Instance Attribute Details

#access_keyObject (readonly)

Returns the value of attribute access_key.



13
14
15
# File 'lib/seko_ecom_api/clients/omni_returns_client.rb', line 13

def access_key
  @access_key
end

#adapterObject (readonly)

Returns the value of attribute adapter.



13
14
15
# File 'lib/seko_ecom_api/clients/omni_returns_client.rb', line 13

def adapter
  @adapter
end

#conn_optsObject (readonly)

Returns the value of attribute conn_opts.



13
14
15
# File 'lib/seko_ecom_api/clients/omni_returns_client.rb', line 13

def conn_opts
  @conn_opts
end

#testObject (readonly)

Returns the value of attribute test.



13
14
15
# File 'lib/seko_ecom_api/clients/omni_returns_client.rb', line 13

def test
  @test
end

Instance Method Details

#connectionObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/seko_ecom_api/clients/omni_returns_client.rb', line 27

def connection
  @connection ||= Faraday.new do |conn|
    conn.url_prefix = test ? TEST_BASE_URL : BASE_URL
    conn.ssl.verify = test ? false : true
    conn.options.merge!(conn_opts)
    conn.headers['Access_Key'] = access_key
    conn.request :json
    conn.response :encoding
    conn.adapter adapter
  end
end

#create_shipment(params) ⇒ Object



22
23
24
25
# File 'lib/seko_ecom_api/clients/omni_returns_client.rb', line 22

def create_shipment(params)
  response = handle_response post_request('labels/printshipment', params: parse_params(params))
  Shipment.new(response)
end