Class: Ecommerce::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, secret) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/ecommerce/client.rb', line 8

def initialize(token, secret)
  @token = token
  @secret = secret
end

Instance Attribute Details

#secretObject (readonly)

Returns the value of attribute secret.



6
7
8
# File 'lib/ecommerce/client.rb', line 6

def secret
  @secret
end

#tokenObject (readonly)

Returns the value of attribute token.



6
7
8
# File 'lib/ecommerce/client.rb', line 6

def token
  @token
end

Instance Method Details

#authenticated?(plan) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'lib/ecommerce/client.rb', line 13

def authenticated?(plan)
  get("/api/orders/#{plan}/") { |response| response.code == 200 }
rescue RequestError => e
  raise e unless [401, 403].include?(e.code)
  false
end