Class: Vend::Client
- Inherits:
-
Object
- Object
- Vend::Client
- Extended by:
- Forwardable
- Includes:
- Logable
- Defined in:
- lib/vend/client.rb
Overview
Main access point which allows resources within the Vend gem to make HTTP requests to the Vend API.
Client must be initialized with:
* a store url (e.g. the storeurl portion of http://storeurl.vendhq.com/),
* a valid username and password
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_OPTIONS =
{}
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#password ⇒ Object
The store url for this client.
-
#store ⇒ Object
The store url for this client.
-
#username ⇒ Object
The store url for this client.
Attributes included from Logable
Instance Method Summary collapse
-
#base_url ⇒ Object
Returns the base API url for the client.
-
#Customer ⇒ Object
:nodoc:.
- #http_client ⇒ Object
- #http_client_options ⇒ Object
-
#initialize(store, username, password, options = {}) ⇒ Client
constructor
:nodoc:.
-
#Outlet ⇒ Object
:nodoc:.
-
#PaymentType ⇒ Object
:nodoc:.
-
#Product ⇒ Object
:nodoc:.
-
#Register ⇒ Object
:nodoc:.
-
#RegisterSale ⇒ Object
:nodoc:.
-
#Supplier ⇒ Object
:nodoc:.
-
#Tax ⇒ Object
:nodoc:.
-
#User ⇒ Object
:nodoc:.
Constructor Details
#initialize(store, username, password, options = {}) ⇒ Client
:nodoc:
23 24 25 26 27 28 |
# File 'lib/vend/client.rb', line 23 def initialize(store, username, password, = {}) #:nodoc: @store = store @username = username @password = password @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/vend/client.rb', line 21 def @options end |
#password ⇒ Object
The store url for this client
20 21 22 |
# File 'lib/vend/client.rb', line 20 def password @password end |
#store ⇒ Object
The store url for this client
20 21 22 |
# File 'lib/vend/client.rb', line 20 def store @store end |
#username ⇒ Object
The store url for this client
20 21 22 |
# File 'lib/vend/client.rb', line 20 def username @username end |
Instance Method Details
#base_url ⇒ Object
Returns the base API url for the client. E.g. for the store ‘foo’, it returns foo.vendhq.com/api/
68 69 70 |
# File 'lib/vend/client.rb', line 68 def base_url "https://#{@store}.vendhq.com/api/" end |
#Customer ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/vend/client.rb', line 38 def Customer #:nodoc: Vend::BaseFactory.new(self, Resource::Customer) end |
#http_client ⇒ Object
72 73 74 |
# File 'lib/vend/client.rb', line 72 def http_client @http_client ||= HttpClient.new() end |
#http_client_options ⇒ Object
76 77 78 79 80 |
# File 'lib/vend/client.rb', line 76 def .merge( base_url: base_url, username: username, password: password ) end |
#Outlet ⇒ Object
:nodoc:
34 35 36 |
# File 'lib/vend/client.rb', line 34 def Outlet #:nodoc: Vend::BaseFactory.new(self, Resource::Outlet) end |
#PaymentType ⇒ Object
:nodoc:
42 43 44 |
# File 'lib/vend/client.rb', line 42 def PaymentType #:nodoc: Vend::BaseFactory.new(self, Resource::PaymentType) end |
#Product ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/vend/client.rb', line 30 def Product #:nodoc: Vend::BaseFactory.new(self, Resource::Product) end |
#Register ⇒ Object
:nodoc:
46 47 48 |
# File 'lib/vend/client.rb', line 46 def Register #:nodoc: Vend::BaseFactory.new(self, Resource::Register) end |
#RegisterSale ⇒ Object
:nodoc:
50 51 52 |
# File 'lib/vend/client.rb', line 50 def RegisterSale #:nodoc: Vend::BaseFactory.new(self, Resource::RegisterSale) end |
#Supplier ⇒ Object
:nodoc:
62 63 64 |
# File 'lib/vend/client.rb', line 62 def Supplier #:nodoc: Vend::BaseFactory.new(self, Resource::Supplier) end |
#Tax ⇒ Object
:nodoc:
54 55 56 |
# File 'lib/vend/client.rb', line 54 def Tax #:nodoc: Vend::BaseFactory.new(self, Resource::Tax) end |
#User ⇒ Object
:nodoc:
58 59 60 |
# File 'lib/vend/client.rb', line 58 def User #:nodoc: Vend::BaseFactory.new(self, Resource::User) end |