Class: ShipStationRuby::Client
- Inherits:
-
Object
- Object
- ShipStationRuby::Client
- Defined in:
- lib/shipstation_ruby/client.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(username = ShipStationRuby.username, password = ShipStationRuby.password) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(username = ShipStationRuby.username, password = ShipStationRuby.password) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 |
# File 'lib/shipstation_ruby/client.rb', line 5 def initialize(username = ShipStationRuby.username, password = ShipStationRuby.password) raise ArgumentError unless username && password @auth = {:username => username, :password => password} @client = OData::Service.new(API_BASE, @auth) self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/shipstation_ruby/client.rb', line 13 def method_missing(method, *args, &block) method = method.to_s = args.last.is_a?(Hash) ? args.pop : {} # method == 'orders' klass = method.pluralize.camelize ShipStationRuby::Collection.new(@client, klass) end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
3 4 5 |
# File 'lib/shipstation_ruby/client.rb', line 3 def auth @auth end |
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/shipstation_ruby/client.rb', line 3 def client @client end |
Instance Method Details
#inspect ⇒ Object
22 23 24 |
# File 'lib/shipstation_ruby/client.rb', line 22 def inspect "#<ShipStationRuby::Client:#{object_id}>" end |