Class: Sendle::Api::Quote

Inherits:
Resource show all
Includes:
Actions::Index
Defined in:
lib/sendle/api/quote.rb

Instance Method Summary collapse

Methods included from Actions::Index

included, #index

Methods inherited from Resource

#method_missing, #process_create_response, #process_destroy_response, #process_index_response, #process_show_response, url, #validate_create_request!

Methods included from Actions::Base

#request

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sendle::Api::Resource

Instance Method Details

#include_credentials?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/sendle/api/quote.rb', line 12

def include_credentials?
  false
end

#urlObject



8
9
10
# File 'lib/sendle/api/quote.rb', line 8

def url
  Sendle::Api.base_url + "quote"
end

#validate_index_request!(params) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sendle/api/quote.rb', line 16

def validate_index_request!(params)
  # Checking for required params
  required = %w( pickup_suburb pickup_postcode delivery_suburb delivery_postcode kilogram_weight)
  validate_presence_of!(required, params)

  # Checking for valid plan_name, if passed in
  if params[:plan_name]
    plan_name = params[:plan_name]
    raise Sendle::Api::Errors::InvalidPlan.new(plan_name) unless Sendle::Api::PLANS.include?(plan_name)
  end
end