Class: Teilashare::APIResource
- Inherits:
-
Object
- Object
- Teilashare::APIResource
- Defined in:
- lib/teilashare/api_resource.rb
Direct Known Subclasses
Resources::CouponDeal, Resources::EditTrail, Resources::Products, Resources::TodayStats, Resources::Traffic, Resources::VoidTrail
Constant Summary collapse
- PATH =
'/x.cfm'
- HOST =
'api.shareasale.com'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #action_verb ⇒ Object
- #call ⇒ Object
-
#initialize(client, opts = {}) ⇒ APIResource
constructor
A new instance of APIResource.
Constructor Details
#initialize(client, opts = {}) ⇒ APIResource
Returns a new instance of APIResource.
10 11 12 13 14 |
# File 'lib/teilashare/api_resource.rb', line 10 def initialize(client, opts = {}) @client = client @opts = default_opts.merge(opts).with_indifferent_access validate_required_opts end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/teilashare/api_resource.rb', line 8 def client @client end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
8 9 10 |
# File 'lib/teilashare/api_resource.rb', line 8 def opts @opts end |
Instance Method Details
#action_verb ⇒ Object
24 25 26 |
# File 'lib/teilashare/api_resource.rb', line 24 def action_verb raise NotImplementedError, 'please define in a subclass' end |
#call ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/teilashare/api_resource.rb', line 16 def call response = Request.new(client, self).call # the API returns 200 OK on invalid authentication GET requests, so need to parse error from body instead raise Errors::InvalidRequestError, response.body if response.body.match?(/\AInvalid Request/) parser.parse(response.body) end |