Class: ShiprocketAPI::PickupLocation
- Defined in:
- lib/shiprocket_api/resources/pickup_location.rb
Defined Under Namespace
Classes: Collection
Constant Summary collapse
- DEFAULT_ATTRS =
{ pickup_location: '', name: '', email: '', phone: '', address: '', address_2: '', city: '', state: '', country: '', pin_code: '' }
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
clear_session, create_session, #initialize, set_prefix, temp_session
Constructor Details
This class inherits a constructor from ShiprocketAPI::Base
Class Method Details
.find_every(options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/shiprocket_api/resources/pickup_location.rb', line 32 def find_every() set_prefix_to_list_all_locations do , = ([:params]) path = collection_path(, ) instantiate_collection((format.decode(connection.get(path, headers).body) || []), , ) 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) ⇒ Object
28 29 30 |
# 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 |
Instance Method Details
#id_from_response(response) ⇒ Object
47 48 49 50 51 |
# 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 |