Class: Lipseys::Shipping

Inherits:
Base
  • Object
show all
Includes:
API
Defined in:
lib/lipseys/shipping.rb

Constant Summary collapse

ENDPOINTS =
{
  fetch: "shipping/oneday".freeze,
}

Constants included from API

API::FILE_UPLOAD_ATTRS, API::ROOT_API_URL, API::USER_AGENT

Instance Method Summary collapse

Methods included from API

#get_request, #post_file_request, #post_request

Constructor Details

#initialize(client) ⇒ Shipping

Returns a new instance of Shipping.



12
13
14
# File 'lib/lipseys/shipping.rb', line 12

def initialize(client)
  @client = client
end

Instance Method Details

#fetch(since_date = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/lipseys/shipping.rb', line 16

def fetch(since_date = nil)
  endpoint = ENDPOINTS[:fetch]
  since_date = (since_date || Time.now.prev_day).strftime('%m/%d/%Y')
  headers  = [
    *auth_header(@client.access_token),
    *content_type_header('application/json'),
  ].to_h

  post_request(endpoint, "\"#{since_date}\"", headers)
end