Class: Unit::ApiToken::Customer::CreateCustomerTokenRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customer_id, scope, verification_token, verification_code = nil, expires_in = nil, resources = nil) ⇒ CreateCustomerTokenRequest

Returns a new instance of CreateCustomerTokenRequest.

Parameters:

  • customer_id (String)
  • scope (Array<String>)
  • verification_token (String)
    • optional

  • verification_code (String) (defaults to: nil)
    • optional

  • expires_in (Integer) (defaults to: nil)
    • optional

  • resources (Array<RestrictedResource>) (defaults to: nil)
    • optional



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

def initialize(customer_id, scope, verification_token, verification_code = nil,
               expires_in = nil, resources = nil)
  @customer_id = customer_id
  @scope = scope
  @verification_token = verification_token
  @verification_code = verification_code
  @expires_in = expires_in
  @resources = resources
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_customer_token_request.rb', line 9

def customer_id
  @customer_id
end

#expires_inObject (readonly)

Returns the value of attribute expires_in.



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

def expires_in
  @expires_in
end

#resourcesObject (readonly)

Returns the value of attribute resources.



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

def resources
  @resources
end

#scopeObject (readonly)

Returns the value of attribute scope.



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

def scope
  @scope
end

#verification_codeObject (readonly)

Returns the value of attribute verification_code.



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

def verification_code
  @verification_code
end

#verification_tokenObject (readonly)

Returns the value of attribute verification_token.



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

def verification_token
  @verification_token
end

Instance Method Details

#to_json_apiObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/unit/models/api_token/customer/create_customer_token_request.rb', line 27

def to_json_api
  result = { data: { type: "customerToken",
                     attributes:
                       { scope: scope&.join(" "),
                         verificationToken: verification_token,
                         verificationCode: verification_code,
                         expiresIn: expires_in,
                         resources: resources } } }
  result[:data][:attributes].compact!
  result.to_json
end