Class: Beslist::API::Client
- Inherits:
-
Object
- Object
- Beslist::API::Client
- Defined in:
- lib/beslist/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #orders(options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 |
# File 'lib/beslist/client.rb', line 8 def initialize( = {}) @connection = Beslist::API::Connection.new( :client_id => [:client_id], :shop_id => [:shop_id], :personal_key => [:personal_key]) end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
6 7 8 |
# File 'lib/beslist/client.rb', line 6 def connection @connection end |
Instance Method Details
#orders(options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/beslist/client.rb', line 14 def orders() date_from, date_to = .delete(:date_from), .delete(:date_to) response = @connection.request do @connection.interface.get do |req| req.url Beslist::API::Config.prefix + '/shoppingcart/shop_orders/' req.params = { checksum: @connection.checksum(date_from, date_to), client_id: @connection.[:client_id], shop_id: @connection.[:shop_id] } req.params.merge!(date_from: date_from) if date_from req.params.merge!(date_to: date_to) if date_to req.params.merge!(output_type: 'test', test_orders: '250') if Beslist::API::Config.mode == 'sandbox' end end if response['shoppingCart']['summary'].keys.include?('errorMessage') fail(Beslist::API::Error, response['shoppingCart']['summary']['errorMessage']) end response end |