class Zara4::API::Communication::Grant::GrantRequest
Attributes
client_id[RW]
client_secret[RW]
scopes[RW]
Public Class Methods
new(client_id, client_secret, scopes)
click to toggle source
Constructor
# File lib/zara4/api/communication/grant/grant_request.rb, line 12 def initialize(client_id, client_secret, scopes) @client_id = client_id @client_secret = client_secret @scopes = scopes end
Public Instance Methods
get_tokens()
click to toggle source
Get tokens from the API
# File lib/zara4/api/communication/grant/grant_request.rb, line 22 def get_tokens url = Zara4::API::Communication::Util::url('/oauth/access_token') parameters = { 'grant_type' => grant_type(), 'client_id' => @client_id, 'client_secret' => @client_secret, 'scope' => @scopes.join(','), } headers = { 'Content-Type' => 'application/json' } response = self.class.post(url, { body: parameters.to_json, headers: headers }) # Check for API error response if response.has_key?('error') puts 'ERROR IS ' + response.fetch('error') end return { 'access_token' => response.fetch('access_token'), 'expires_in' => response.fetch('expires_in'), } end
with_image_processing()
click to toggle source
Add image processing to the request scope.
# File lib/zara4/api/communication/grant/grant_request.rb, line 58 def with_image_processing @scopes.push('image-processing') end
with_usage()
click to toggle source
Add usage to the request scope.
# File lib/zara4/api/communication/grant/grant_request.rb, line 66 def with_usage @scopes.push('usage') end