Class: Api2cart::Store
- Inherits:
-
Object
- Object
- Api2cart::Store
- Defined in:
- lib/api2cart/store.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#store_key ⇒ Object
Returns the value of attribute store_key.
Instance Method Summary collapse
-
#initialize(api_key, store_key, proxy: nil) ⇒ Store
constructor
A new instance of Store.
- #method_missing(method_name, *args) ⇒ Object
Constructor Details
#initialize(api_key, store_key, proxy: nil) ⇒ Store
Returns a new instance of Store.
5 6 7 8 9 |
# File 'lib/api2cart/store.rb', line 5 def initialize(api_key, store_key, proxy: nil) self.api_key = api_key self.store_key = store_key self.proxy = proxy end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/api2cart/store.rb', line 11 def method_missing(method_name, *args) request_url = RequestUrlComposer.new(api_key, store_key, method_name, args.first).compose_request_url api2cart_client = Client.new(request_url, proxy) api2cart_client.make_request! if api2cart_client.successful? api2cart_client.result else raise api2cart_client. end end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/api2cart/store.rb', line 3 def api_key @api_key end |
#proxy ⇒ Object
Returns the value of attribute proxy.
3 4 5 |
# File 'lib/api2cart/store.rb', line 3 def proxy @proxy end |
#store_key ⇒ Object
Returns the value of attribute store_key.
3 4 5 |
# File 'lib/api2cart/store.rb', line 3 def store_key @store_key end |