module Shiphawk::Api::QueryHelpers

Public Instance Methods

catalog_sale_path() click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 42
def catalog_sale_path
  notifications_path "catalog_sale"
end
categories_path(sub_path=nil) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 10
def categories_path sub_path=nil
  "categories/#{sub_path}"
end
collection_request(path, count=100) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 50
def collection_request path, count=100
  page = 1
  entities = []
  loop do
    response = get_request path, {page: page, per_page: count, api_token: self.api_token}
    entities << response.body
    entities = entities.flatten
    break if entities.size >= response.headers['X-Total'].to_i
    page += 1
  end
  entities
end
entity_request_with_id(path, id) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 63
def entity_request_with_id path, id
  get_request "#{path}#{id}", {}
end
entity_request_with_options(path, options) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 67
def entity_request_with_options path, options
  get_request path, options
end
items_path(sub_path=nil) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 6
def items_path sub_path=nil
  "items/#{sub_path}"
end
notes_path(id) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 22
def notes_path id
  shipments_path "#{id}/notes"
end
notifications_path(sub_path=nil) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 38
def notifications_path sub_path=nil
  "notifications/#{sub_path}"
end
products_path(sub_path=nil) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 14
def products_path sub_path=nil
  "products/#{sub_path}"
end
rates_path(sub_path=nil) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 18
def rates_path sub_path=nil
  "rates/#{sub_path}"
end
shipments_path(sub_path=nil) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 30
def shipments_path sub_path=nil
  "shipments/#{sub_path}"
end
status_path() click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 34
def status_path
  shipments_path "status"
end
tracking_path(id) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 26
def tracking_path id
  shipments_path "#{id}/tracking"
end
zip_codes_path(sub_path=nil) click to toggle source
# File lib/shiphawk/api/query_helpers.rb, line 46
def zip_codes_path sub_path=nil
  "zip_codes/#{sub_path}"
end