Class: Sheepla::API
- Inherits:
-
Object
- Object
- Sheepla::API
- Defined in:
- lib/sheepla.rb
Constant Summary collapse
- BASE_URL =
'https://api.sheepla.com/'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#http ⇒ Object
Returns the value of attribute http.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #add_shipment_to_order(external_order_id) ⇒ Object
- #create_order(params) ⇒ Object
-
#initialize(api_key) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(api_key) ⇒ API
Returns a new instance of API.
14 15 16 |
# File 'lib/sheepla.rb', line 14 def initialize(api_key) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/sheepla.rb', line 12 def api_key @api_key end |
#http ⇒ Object
Returns the value of attribute http.
12 13 14 |
# File 'lib/sheepla.rb', line 12 def http @http end |
#uri ⇒ Object
Returns the value of attribute uri.
12 13 14 |
# File 'lib/sheepla.rb', line 12 def uri @uri end |
Instance Method Details
#add_shipment_to_order(external_order_id) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sheepla.rb', line 27 def add_shipment_to_order(external_order_id) connection('addShipmentToOrder') body = body_wrapper('addShipmentToOrderRequest') do |xml| xml.orders do xml.order do xml.externalOrderId external_order_id end end end request_method(body) end |
#create_order(params) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/sheepla.rb', line 18 def create_order(params) order = params.deep_transform_keys{ |key| key.to_s.camelize(:lower) } # raise ApiError.new("Order parameters don't contain all obligatory keys") unless validate_order(order) connection('createOrder') request_method(build_order(order)) end |