Class: Sendle::Api::Order
- Includes:
- Actions::Create, Actions::Destroy, Actions::Show
- Defined in:
- lib/sendle/api/order.rb
Instance Method Summary collapse
Methods included from Actions::Destroy
Methods included from Actions::Show
Methods included from Actions::Create
Methods inherited from Resource
#include_credentials?, #method_missing, #process_create_response, #process_destroy_response, #process_index_response, #process_show_response, url, #validate_index_request!
Methods included from Actions::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sendle::Api::Resource
Instance Method Details
#url ⇒ Object
6 7 8 |
# File 'lib/sendle/api/order.rb', line 6 def url Sendle::Api.base_url + "orders" end |
#validate_create_request!(params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sendle/api/order.rb', line 10 def validate_create_request!(params) # Checking for required params of parcel required = %w( pickup_date kilogram_weight cubic_metre_volume ) validate_presence_of!(required, params) # Checking for sender params raise Sendle::Api::Errors::MissingParams.new(['sender']) unless hash_contains?(params, :sender) sender_params = params[:sender] raise Sendle::Api::Errors::MissingParams.new(['sender:contact']) unless hash_contains?(sender_params, :contact) required = %w( name phone ) validate_presence_of!(required, sender_params[:contact]) raise Sendle::Api::Errors::MissingParams.new(['sender:address']) unless hash_contains?(sender_params, :address) required = %w( address_line1 suburb postcode state_name ) validate_presence_of!(required, sender_params[:address]) # Checking for receiver params raise Sendle::Api::Errors::MissingParams.new(['receiver']) unless hash_contains?(params, :receiver) receiver_params = params[:receiver] raise Sendle::Api::Errors::MissingParams.new(['receiver:contact']) unless hash_contains?(receiver_params, :contact) required = %w( name ) validate_presence_of!(required, receiver_params[:contact]) raise Sendle::Api::Errors::MissingParams.new(['receiver:address']) unless hash_contains?(receiver_params, :address) required = %w( address_line1 suburb postcode state_name ) validate_presence_of!(required, receiver_params[:address]) end |