Class: Shiphawk::Client

Constant Summary collapse

PRODUCTION_API_HOST =
'https://shiphawk.com'
SANDBOX_API_HOST =
'https://sandbox.shiphawk.com'
DEFAULT_API_VERSION =
'v3'

Constants included from Helpers::Request

Helpers::Request::API_PATH, Helpers::Request::APP_VERSION, Helpers::Request::DEFAULT_HEADERS

Instance Attribute Summary collapse

Attributes included from Helpers::Request

#adapter, #api_version, #connection, #host_url

Instance Method Summary collapse

Methods included from Api::Notifications

#catalog_sale_create

Methods included from Api::ZipCodes

#zip_codes_index, #zip_codes_search

Methods included from Api::ShipmentsStatus

#shipments_status_update

Methods included from Api::Shipments

#shipments_bol, #shipments_bol_pdf, #shipments_create, #shipments_destroy, #shipments_index, #shipments_show, #shipments_update

Methods included from Api::ShipmentTracking

#shipments_status_show, #shipments_status_update

Methods included from Api::ShipmentNotes

#shipment_notes_show, #shipment_notes_update

Methods included from Api::Rates

#rates_create, #rates_show

Methods included from Api::Items

#items_index, #items_search, #items_show

Methods included from Api::QueryHelpers

#catalog_sale_path, #categories_path, #collection_request, #entity_request_with_id, #entity_request_with_options, #items_path, #notes_path, #notifications_path, #products_path, #rates_path, #shipments_path, #status_path, #tracking_path, #zip_codes_path

Constructor Details

#initialize(options = {api_token: Shiphawk.api_token}) ⇒ Client

Returns a new instance of Client.



21
22
23
24
25
26
27
28
# File 'lib/shiphawk/client.rb', line 21

def initialize(options={api_token: Shiphawk.api_token})
  host = Shiphawk.sandbox ? SANDBOX_API_HOST : PRODUCTION_API_HOST
  @options = options
  @api_token = @options.delete(:api_token) { |key| Shiphawk.api_token }
  @api_version = @options.delete(:api_version) { |key| DEFAULT_API_VERSION }
  @host_url = @options.delete(:host_url) { |key| host }
  @adapter = @options.delete(:adapter) { |key| Faraday.default_adapter }
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



19
20
21
# File 'lib/shiphawk/client.rb', line 19

def api_token
  @api_token
end

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/shiphawk/client.rb', line 19

def options
  @options
end

#sandboxObject (readonly)

Returns the value of attribute sandbox.



19
20
21
# File 'lib/shiphawk/client.rb', line 19

def sandbox
  @sandbox
end