Class: WalmartApIs::ClientRegistrationRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/client_registration_request.rb

Overview

RFC 7591 ยง2 client metadata.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(redirect_uris:, token_endpoint_auth_method: TokenEndpointAuthMethod::NONE, grant_types: SKIP, response_types: SKIP, client_name: SKIP, scope: SKIP, client_uri: SKIP, logo_uri: SKIP, contacts: SKIP, additional_properties: nil) ⇒ ClientRegistrationRequest

Returns a new instance of ClientRegistrationRequest.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 85

def initialize(redirect_uris:,
               token_endpoint_auth_method: TokenEndpointAuthMethod::NONE,
               grant_types: SKIP, response_types: SKIP, client_name: SKIP,
               scope: SKIP, client_uri: SKIP, logo_uri: SKIP,
               contacts: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @redirect_uris = redirect_uris
  unless token_endpoint_auth_method == SKIP
    @token_endpoint_auth_method =
      token_endpoint_auth_method
  end
  @grant_types = grant_types unless grant_types == SKIP
  @response_types = response_types unless response_types == SKIP
  @client_name = client_name unless client_name == SKIP
  @scope = scope unless scope == SKIP
  @client_uri = client_uri unless client_uri == SKIP
  @logo_uri = logo_uri unless logo_uri == SKIP
  @contacts = contacts unless contacts == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#client_nameString

Human-readable name shown on the consent screen.

Returns:

  • (String)


32
33
34
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 32

def client_name
  @client_name
end

#client_uriString

Homepage of the client.

Returns:

  • (String)


41
42
43
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 41

def client_uri
  @client_uri
end

#contactsArray[String]

Contact emails for the client.

Returns:

  • (Array[String])


49
50
51
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 49

def contacts
  @contacts
end

#grant_typesArray[GrantType1]

Grants the client will use.

Returns:



24
25
26
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 24

def grant_types
  @grant_types
end

#logo_uriString

Logo shown on the consent screen.

Returns:

  • (String)


45
46
47
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 45

def logo_uri
  @logo_uri
end

#redirect_urisArray[String]

Registered callback URIs. Enforced by exact match at authorize. HTTPS (or localhost).

Returns:

  • (Array[String])


15
16
17
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 15

def redirect_uris
  @redirect_uris
end

#response_typesArray[ResponseType]

Must be [code].

Returns:



28
29
30
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 28

def response_types
  @response_types
end

#scopeString

Space-delimited scopes the client may request (subset of the sellerAuth catalog + offline_access).

Returns:

  • (String)


37
38
39
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 37

def scope
  @scope
end

#token_endpoint_auth_methodTokenEndpointAuthMethod

none for public clients (PKCE), client_secret_post/client_secret_basic for confidential.



20
21
22
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 20

def token_endpoint_auth_method
  @token_endpoint_auth_method
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 109

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  redirect_uris = hash.key?('redirect_uris') ? hash['redirect_uris'] : nil
  token_endpoint_auth_method =
    hash['token_endpoint_auth_method'] ||= TokenEndpointAuthMethod::NONE
  grant_types = hash.key?('grant_types') ? hash['grant_types'] : SKIP
  response_types =
    hash.key?('response_types') ? hash['response_types'] : SKIP
  client_name = hash.key?('client_name') ? hash['client_name'] : SKIP
  scope = hash.key?('scope') ? hash['scope'] : SKIP
  client_uri = hash.key?('client_uri') ? hash['client_uri'] : SKIP
  logo_uri = hash.key?('logo_uri') ? hash['logo_uri'] : SKIP
  contacts = hash.key?('contacts') ? hash['contacts'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  ClientRegistrationRequest.new(redirect_uris: redirect_uris,
                                token_endpoint_auth_method: token_endpoint_auth_method,
                                grant_types: grant_types,
                                response_types: response_types,
                                client_name: client_name,
                                scope: scope,
                                client_uri: client_uri,
                                logo_uri: logo_uri,
                                contacts: contacts,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 52

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['redirect_uris'] = 'redirect_uris'
  @_hash['token_endpoint_auth_method'] = 'token_endpoint_auth_method'
  @_hash['grant_types'] = 'grant_types'
  @_hash['response_types'] = 'response_types'
  @_hash['client_name'] = 'client_name'
  @_hash['scope'] = 'scope'
  @_hash['client_uri'] = 'client_uri'
  @_hash['logo_uri'] = 'logo_uri'
  @_hash['contacts'] = 'contacts'
  @_hash
end

.nullablesObject

An array for nullable fields



81
82
83
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 81

def self.nullables
  []
end

.optionalsObject

An array for optional fields



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 67

def self.optionals
  %w[
    token_endpoint_auth_method
    grant_types
    response_types
    client_name
    scope
    client_uri
    logo_uri
    contacts
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



156
157
158
159
160
161
162
163
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 156

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} redirect_uris: #{@redirect_uris.inspect}, token_endpoint_auth_method:"\
  " #{@token_endpoint_auth_method.inspect}, grant_types: #{@grant_types.inspect},"\
  " response_types: #{@response_types.inspect}, client_name: #{@client_name.inspect}, scope:"\
  " #{@scope.inspect}, client_uri: #{@client_uri.inspect}, logo_uri: #{@logo_uri.inspect},"\
  " contacts: #{@contacts.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



146
147
148
149
150
151
152
153
# File 'lib/walmart_ap_is/models/client_registration_request.rb', line 146

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} redirect_uris: #{@redirect_uris}, token_endpoint_auth_method:"\
  " #{@token_endpoint_auth_method}, grant_types: #{@grant_types}, response_types:"\
  " #{@response_types}, client_name: #{@client_name}, scope: #{@scope}, client_uri:"\
  " #{@client_uri}, logo_uri: #{@logo_uri}, contacts: #{@contacts}, additional_properties:"\
  " #{@additional_properties}>"
end