Class: ShipStationRuby::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/shipstation_ruby/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username = ShipStationRuby.username, password = ShipStationRuby.password) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


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
  options = args.last.is_a?(Hash) ? args.pop : {}

  # method == 'orders'
  klass = method.pluralize.camelize
  ShipStationRuby::Collection.new(@client, klass)
end

Instance Attribute Details

#authObject

Returns the value of attribute auth.



3
4
5
# File 'lib/shipstation_ruby/client.rb', line 3

def auth
  @auth
end

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/shipstation_ruby/client.rb', line 3

def client
  @client
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/shipstation_ruby/client.rb', line 22

def inspect
  "#<ShipStationRuby::Client:#{object_id}>"
end