Class: Monri::AccessTokens
- Inherits:
-
Object
- Object
- Monri::AccessTokens
- Defined in:
- lib/monri/access_tokens.rb,
lib/monri/access_tokens/create_response.rb
Defined Under Namespace
Classes: CreateResponse
Instance Attribute Summary collapse
Instance Method Summary collapse
- #create(options) ⇒ Monri::AccessTokens::CreateResponse
- #create!(options) ⇒ Monri::AccessTokens::CreateResponse
Instance Attribute Details
#http_client=(value) ⇒ Monri::HttpClient (writeonly)
8 9 10 |
# File 'lib/monri/access_tokens.rb', line 8 def http_client=(value) @http_client = value end |
Instance Method Details
#create(options) ⇒ Monri::AccessTokens::CreateResponse
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/monri/access_tokens.rb', line 23 def create() Monri::AccessTokens::CreateResponse.create do body = { client_id: config.authenticity_token, client_secret: config.merchant_key, grant_type: 'client_credentials', scopes: .delete(:scopes) || [] } response = @http_client.post('/v2/oauth', body) if response.failed? raise response.exception elsif response.success? response.body else # TODO: handle this case end end end |
#create!(options) ⇒ Monri::AccessTokens::CreateResponse
12 13 14 15 16 17 18 19 |
# File 'lib/monri/access_tokens.rb', line 12 def create!() rv = create() if rv.failed? #noinspection RubyMismatchedArgumentType raise rv.exception end rv end |