Module: Shiphawk::Api::QueryHelpers
- Included in:
- Client
- Defined in:
- lib/shiphawk/api/query_helpers.rb
Instance Method Summary collapse
- #catalog_sale_path ⇒ Object
- #categories_path(sub_path = nil) ⇒ Object
- #collection_request(path, count = 100) ⇒ Object
- #entity_request_with_id(path, id) ⇒ Object
- #entity_request_with_options(path, options) ⇒ Object
- #items_path(sub_path = nil) ⇒ Object
- #notes_path(id) ⇒ Object
- #notifications_path(sub_path = nil) ⇒ Object
- #products_path(sub_path = nil) ⇒ Object
- #rates_path(sub_path = nil) ⇒ Object
- #shipments_path(sub_path = nil) ⇒ Object
- #status_path ⇒ Object
- #tracking_path(id) ⇒ Object
- #zip_codes_path(sub_path = nil) ⇒ Object
Instance Method Details
#catalog_sale_path ⇒ Object
42 43 44 |
# File 'lib/shiphawk/api/query_helpers.rb', line 42 def catalog_sale_path notifications_path "catalog_sale" end |
#categories_path(sub_path = nil) ⇒ Object
10 11 12 |
# File 'lib/shiphawk/api/query_helpers.rb', line 10 def categories_path sub_path=nil "categories/#{sub_path}" end |
#collection_request(path, count = 100) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# 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) ⇒ Object
63 64 65 |
# 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) ⇒ Object
67 68 69 |
# File 'lib/shiphawk/api/query_helpers.rb', line 67 def path, get_request path, end |
#items_path(sub_path = nil) ⇒ Object
6 7 8 |
# File 'lib/shiphawk/api/query_helpers.rb', line 6 def items_path sub_path=nil "items/#{sub_path}" end |
#notes_path(id) ⇒ Object
22 23 24 |
# File 'lib/shiphawk/api/query_helpers.rb', line 22 def notes_path id shipments_path "#{id}/notes" end |
#notifications_path(sub_path = nil) ⇒ Object
38 39 40 |
# File 'lib/shiphawk/api/query_helpers.rb', line 38 def notifications_path sub_path=nil "notifications/#{sub_path}" end |
#products_path(sub_path = nil) ⇒ Object
14 15 16 |
# File 'lib/shiphawk/api/query_helpers.rb', line 14 def products_path sub_path=nil "products/#{sub_path}" end |
#rates_path(sub_path = nil) ⇒ Object
18 19 20 |
# File 'lib/shiphawk/api/query_helpers.rb', line 18 def rates_path sub_path=nil "rates/#{sub_path}" end |
#shipments_path(sub_path = nil) ⇒ Object
30 31 32 |
# File 'lib/shiphawk/api/query_helpers.rb', line 30 def shipments_path sub_path=nil "shipments/#{sub_path}" end |
#status_path ⇒ Object
34 35 36 |
# File 'lib/shiphawk/api/query_helpers.rb', line 34 def status_path shipments_path "status" end |
#tracking_path(id) ⇒ Object
26 27 28 |
# File 'lib/shiphawk/api/query_helpers.rb', line 26 def tracking_path id shipments_path "#{id}/tracking" end |
#zip_codes_path(sub_path = nil) ⇒ Object
46 47 48 |
# File 'lib/shiphawk/api/query_helpers.rb', line 46 def zip_codes_path sub_path=nil "zip_codes/#{sub_path}" end |