Class: Unit::ApiToken::Customer::CreateTokenUsingJwtRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/api_token/customer/create_token_using_jwt_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customer_id, scope, jwt_token = nil) ⇒ CreateTokenUsingJwtRequest

Returns a new instance of CreateTokenUsingJwtRequest.

Parameters:

  • scope (Array<String>)
  • jwt_token (String) (defaults to: nil)


13
14
15
16
17
# File 'lib/unit/models/api_token/customer/create_token_using_jwt_request.rb', line 13

def initialize(customer_id, scope, jwt_token = nil)
  @customer_id = customer_id
  @scope = scope
  @jwt_token = jwt_token
end

Instance Attribute Details

#customer_idObject (readonly)

Returns the value of attribute customer_id.



9
10
11
# File 'lib/unit/models/api_token/customer/create_token_using_jwt_request.rb', line 9

def customer_id
  @customer_id
end

#jwt_tokenObject (readonly)

Returns the value of attribute jwt_token.



9
10
11
# File 'lib/unit/models/api_token/customer/create_token_using_jwt_request.rb', line 9

def jwt_token
  @jwt_token
end

#scopeObject (readonly)

Returns the value of attribute scope.



9
10
11
# File 'lib/unit/models/api_token/customer/create_token_using_jwt_request.rb', line 9

def scope
  @scope
end

Instance Method Details

#to_json_apiObject



19
20
21
22
23
24
25
26
# File 'lib/unit/models/api_token/customer/create_token_using_jwt_request.rb', line 19

def to_json_api
  result = { data: { type: "customerToken",
                     attributes:
                       { scope: scope&.join(" "),
                         jwtToken: jwt_token } } }
  result[:data][:attributes].compact!
  result.to_json
end