class ShiprocketAPI::PickupLocation

Constants

DEFAULT_ATTRS

Public Class Methods

find_every(options) click to toggle source
# File lib/shiprocket_api/resources/pickup_location.rb, line 32
def find_every(options)
  set_prefix_to_list_all_locations do
    prefix_options, query_options = split_options(options[:params])
    path = collection_path(prefix_options, query_options)
    instantiate_collection((format.decode(connection.get(path, headers).body) || []), query_options,
                           prefix_options)
  rescue ActiveResource::ResourceNotFound
    # Swallowing ResourceNotFound exceptions and return nil - as per
    # ActiveRecord.
    set_prefix_to_add
    nil
  end
end
set_prefix_to_list_all_locations(&block) click to toggle source
# File lib/shiprocket_api/resources/pickup_location.rb, line 28
def set_prefix_to_list_all_locations(&block)
  set_prefix("#{Base.prefix}/settings/company/pickup", &block)
end

Public Instance Methods

id_from_response(response) click to toggle source
# File lib/shiprocket_api/resources/pickup_location.rb, line 47
def id_from_response(response)
  JSON.parse(response.body).dig('address', 'id')
rescue JSON::ParserError
  nil
end