authlete 1.0.24 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Makefile +40 -0
  4. data/Rakefile +5 -0
  5. data/authlete.gemspec +2 -2
  6. data/lib/authlete.rb +28 -9
  7. data/lib/authlete/api.rb +146 -321
  8. data/lib/authlete/authentication-server.rb +2 -2
  9. data/lib/authlete/exception.rb +14 -15
  10. data/lib/authlete/model/base.rb +30 -0
  11. data/lib/authlete/model/client-extension.rb +17 -119
  12. data/lib/authlete/model/client.rb +196 -345
  13. data/lib/authlete/model/hashable.rb +13 -33
  14. data/lib/authlete/model/named-uri.rb +13 -74
  15. data/lib/authlete/model/pair.rb +13 -74
  16. data/lib/authlete/model/param-initializer.rb +45 -0
  17. data/lib/authlete/model/property.rb +15 -85
  18. data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
  19. data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
  20. data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
  21. data/lib/authlete/model/request/authorization-request.rb +8 -73
  22. data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
  23. data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
  24. data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
  25. data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
  26. data/lib/authlete/model/request/base.rb +26 -0
  27. data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
  28. data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
  29. data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
  30. data/lib/authlete/model/request/client-registration-request.rb +49 -0
  31. data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
  32. data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
  33. data/lib/authlete/model/request/device-authorization-request.rb +63 -0
  34. data/lib/authlete/model/request/device-complete-request.rb +99 -0
  35. data/lib/authlete/model/request/device-verification-request.rb +40 -0
  36. data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
  37. data/lib/authlete/model/request/introspection-request.rb +24 -83
  38. data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
  39. data/lib/authlete/model/request/revocation-request.rb +14 -88
  40. data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
  41. data/lib/authlete/model/request/token-create-request.rb +52 -183
  42. data/lib/authlete/model/request/token-fail-request.rb +12 -74
  43. data/lib/authlete/model/request/token-issue-request.rb +22 -80
  44. data/lib/authlete/model/request/token-request.rb +44 -81
  45. data/lib/authlete/model/request/token-update-request.rb +35 -121
  46. data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
  47. data/lib/authlete/model/request/user-info-request.rb +25 -70
  48. data/lib/authlete/model/response/access-token.rb +96 -0
  49. data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
  50. data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
  51. data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
  52. data/lib/authlete/model/response/authorization-response.rb +97 -123
  53. data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
  54. data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
  55. data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
  56. data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
  57. data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
  58. data/lib/authlete/model/response/client-list-response.rb +58 -0
  59. data/lib/authlete/model/response/client-registration-response.rb +50 -0
  60. data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
  61. data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
  62. data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
  63. data/lib/authlete/model/response/device-authorization-response.rb +134 -0
  64. data/lib/authlete/model/response/device-complete-response.rb +39 -0
  65. data/lib/authlete/model/response/device-verification-response.rb +96 -0
  66. data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
  67. data/lib/authlete/model/response/introspection-response.rb +64 -58
  68. data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
  69. data/lib/authlete/model/response/revocation-response.rb +12 -15
  70. data/lib/authlete/model/response/service-list-response.rb +54 -0
  71. data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
  72. data/lib/authlete/model/response/token-create-response.rb +50 -55
  73. data/lib/authlete/model/response/token-fail-response.rb +14 -17
  74. data/lib/authlete/model/response/token-issue-response.rb +49 -62
  75. data/lib/authlete/model/response/token-list-response.rb +64 -0
  76. data/lib/authlete/model/response/token-response.rb +59 -79
  77. data/lib/authlete/model/response/token-update-response.rb +28 -23
  78. data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
  79. data/lib/authlete/model/response/user-info-response.rb +48 -42
  80. data/lib/authlete/model/result.rb +14 -13
  81. data/lib/authlete/model/scope.rb +29 -119
  82. data/lib/authlete/model/service-owner.rb +32 -116
  83. data/lib/authlete/model/service.rb +464 -685
  84. data/lib/authlete/model/sns-credentials.rb +18 -91
  85. data/lib/authlete/model/tagged-value.rb +14 -69
  86. data/lib/authlete/utility.rb +3 -32
  87. data/lib/authlete/version.rb +3 -3
  88. data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
  89. data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
  90. data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
  91. data/test/authlete/model/request/test_authorization-request.rb +57 -0
  92. data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
  93. data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
  94. data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
  95. data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
  96. data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
  97. data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
  98. data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
  99. data/test/authlete/model/request/test_client-registration-request.rb +68 -0
  100. data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
  101. data/test/authlete/model/request/test_device-complete-request.rb +102 -0
  102. data/test/authlete/model/request/test_device-verification-request.rb +57 -0
  103. data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
  104. data/test/authlete/model/request/test_introspection-request.rb +79 -0
  105. data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
  106. data/test/authlete/model/request/test_revocation-request.rb +67 -0
  107. data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
  108. data/test/authlete/model/request/test_token-create-request.rb +110 -0
  109. data/test/authlete/model/request/test_token-fail-request.rb +63 -0
  110. data/test/authlete/model/request/test_token-issue-request.rb +70 -0
  111. data/test/authlete/model/request/test_token-request.rb +94 -0
  112. data/test/authlete/model/request/test_token-update-request.rb +82 -0
  113. data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
  114. data/test/authlete/model/request/test_user-info-request.rb +75 -0
  115. data/test/authlete/model/response/test_access-token.rb +101 -0
  116. data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
  117. data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
  118. data/test/authlete/model/response/test_authorization-response.rb +145 -0
  119. data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
  120. data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
  121. data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
  122. data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
  123. data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
  124. data/test/authlete/model/response/test_client-list-response.rb +79 -0
  125. data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
  126. data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
  127. data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
  128. data/test/authlete/model/response/test_device-complete-response.rb +64 -0
  129. data/test/authlete/model/response/test_device-verification-response.rb +112 -0
  130. data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
  131. data/test/authlete/model/response/test_introspection-response.rb +127 -0
  132. data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
  133. data/test/authlete/model/response/test_revocation-response.rb +68 -0
  134. data/test/authlete/model/response/test_service-list-response.rb +72 -0
  135. data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
  136. data/test/authlete/model/response/test_token-create-response.rb +107 -0
  137. data/test/authlete/model/response/test_token-fail-response.rb +68 -0
  138. data/test/authlete/model/response/test_token-issue-response.rb +127 -0
  139. data/test/authlete/model/response/test_token-list-response.rb +84 -0
  140. data/test/authlete/model/response/test_token-response.rb +147 -0
  141. data/test/authlete/model/response/test_token-update-response.rb +87 -0
  142. data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
  143. data/test/authlete/model/response/test_user-info-response.rb +107 -0
  144. data/test/authlete/model/test_client-extension.rb +95 -0
  145. data/test/authlete/model/test_client.rb +461 -0
  146. data/test/authlete/model/test_named-uri.rb +85 -0
  147. data/test/authlete/model/test_pair.rb +85 -0
  148. data/test/authlete/model/test_property.rb +90 -0
  149. data/test/authlete/model/test_result.rb +68 -0
  150. data/test/authlete/model/test_scope.rb +106 -0
  151. data/test/authlete/model/test_service-owner.rb +80 -0
  152. data/test/authlete/model/test_service.rb +614 -0
  153. data/test/authlete/model/test_sns-credentials.rb +88 -0
  154. data/test/authlete/model/test_tagged-value.rb +83 -0
  155. data/test/authlete/test_exception.rb +70 -0
  156. metadata +169 -9
  157. data/lib/authlete/model/client-list.rb +0 -129
  158. data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
  159. data/lib/authlete/model/response/service-creatable-response.rb +0 -51
  160. data/lib/authlete/model/service-list.rb +0 -128
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -15,77 +15,85 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
- require 'json'
19
-
20
-
21
18
  module Authlete
22
19
  module Model
23
20
  module Request
24
- # == Authlete::Model::Request::AuthenticationCallbackRequest class
25
- #
26
- # This class represents a request to an authentication callback endpoint.
27
- class AuthenticationCallbackRequest
28
- include Authlete::Utility
29
- # The API key of the service.
30
- attr_accessor :service_api_key
31
-
32
- # The ID of the client application which has triggered the authentication
33
- # callback request.
34
- attr_accessor :client_id
35
-
36
- # The login ID that the end-user input to the login ID field.
21
+ class AuthenticationCallbackRequest < Authlete::Model::Request::Base
22
+
23
+ attr_accessor :serviceApiKey
24
+ alias_method :service_api_key, :serviceApiKey
25
+ alias_method :service_api_key=, :serviceApiKey=
26
+
27
+ attr_accessor :clientId
28
+ alias_method :client_id, :clientId
29
+ alias_method :client_id=, :clientId=
30
+
37
31
  attr_accessor :id
38
32
 
39
- # The password that the end-user input to the password field.
40
33
  attr_accessor :password
41
34
 
42
- # Names of requested claims (string array).
43
35
  attr_accessor :claims
44
36
 
45
- # Names of requested claim locales (string array). The values come
46
- # from 'claims_locales' request parameter of an authorization request.
47
- attr_accessor :claims_locales
37
+ attr_accessor :claimsLocales
38
+ alias_method :claims_locales, :claimsLocales
39
+ alias_method :claims_locales=, :claimsLocales=
48
40
 
49
- # The SNS which the end-user used for social login.
50
- # For example, 'FACEBOOK'.
51
41
  attr_accessor :sns
52
42
 
53
- # The access token issued at the token endpoint of the SNS.
54
- attr_accessor :access_token
55
-
56
- # The refresh token issued along with the access token.
57
- attr_accessor :refresh_token
58
-
59
- # The duration of the access token.
60
- attr_accessor :expires_in
61
-
62
- # The raw content of the response from the token endpoint of the SNS.
63
- # Correct OAuth 2.0 implementations return 'application/json', but Facebook
64
- # returns 'application/x-www-form-url-encoded'.
65
- attr_accessor :raw_token_response
66
-
67
- # The constructor which takes a hash that represents a JSON request
68
- # to an authentication callback endpoint.
69
- def initialize(hash = {})
70
- @service_api_key = extract_value(hash, :serviceApiKey)
71
- @client_id = extract_value(hash, :clientId)
72
- @id = extract_value(hash, :id)
73
- @password = extract_value(hash, :password)
74
- @claims = extract_value(hash, :claims)
75
- @claims_locales = extract_value(hash, :claimsLocales)
76
- @sns = extract_value(hash, :sns)
77
- @access_token = extract_value(hash, :accessToken)
78
- @refresh_token = extract_value(hash, :refreshToken)
79
- @expires_in = extract_integer_value(hash, :expiresIn)
80
- @raw_token_response = extract_value(hash, :rawTokenResponse)
43
+ attr_accessor :accessToken
44
+ alias_method :access_token, :accessToken
45
+ alias_method :access_token=, :accessToken=
46
+
47
+ attr_accessor :refreshToken
48
+ alias_method :refresh_token, :refreshToken
49
+ alias_method :refresh_token=, :refreshToken=
50
+
51
+ attr_accessor :expiresIn
52
+ alias_method :expires_in, :expiresIn
53
+ alias_method :expires_in=, :expiresIn=
54
+
55
+ attr_accessor :rawTokenResponse
56
+ alias_method :raw_token_response, :rawTokenResponse
57
+ alias_method :raw_token_response=, :rawTokenResponse=
58
+
59
+ private
60
+
61
+ def defaults
62
+ {
63
+ serviceApiKey: nil,
64
+ clientId: 0,
65
+ id: nil,
66
+ password: nil,
67
+ claims: nil,
68
+ claimsLocales: nil,
69
+ sns: nil,
70
+ accessToken: nil,
71
+ refreshToken: nil,
72
+ expiresIn: 0,
73
+ rawTokenResponse: nil
74
+ }
75
+ end
76
+
77
+ def set_params(hash)
78
+ @serviceApiKey = hash[:serviceApiKey]
79
+ @clientId = hash[:clientId]
80
+ @id = hash[:id]
81
+ @password = hash[:password]
82
+ @claims = hash[:claims]
83
+ @claimsLocales = hash[:claimsLocales]
84
+ @sns = hash[:sns]
85
+ @accessToken = hash[:accessToken]
86
+ @refreshToken = hash[:refreshToken]
87
+ @expiresIn = hash[:expiresIn]
88
+ @rawTokenResponse = hash[:rawTokenResponse]
81
89
  end
82
90
 
83
- # Parse a JSON string which represents a request to an authentication
84
- # callback endpoint and generate an instance of AuthenticationCallbackRequest.
91
+ public
92
+
85
93
  def self.parse(json)
86
94
  AuthenticationCallbackRequest.new(JSON.parse(json))
87
95
  end
88
96
  end
89
97
  end
90
98
  end
91
- end
99
+ end
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -15,94 +15,33 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
- require 'set'
19
-
20
-
21
18
  module Authlete
22
19
  module Model
23
20
  module Request
24
- # == Authlete::Model::Request::AuthorizationFailRequest class
25
- #
26
- # This class represents a request to Authlete's /api/auth/authorization/fail API.
27
- class AuthorizationFailRequest < Authlete::Model::Hashable
28
- # The ticket issued by Authlete's /api/auth/authorization API. (String)
21
+ class AuthorizationFailRequest < Authlete::Model::Request::Base
22
+
29
23
  attr_accessor :ticket
30
24
 
31
- # The reason of the failure. (String)
32
25
  attr_accessor :reason
33
26
 
34
- # The custom description about the failure. (String)
35
27
  attr_accessor :description
36
28
 
37
29
  private
38
30
 
39
- # String attributes.
40
- STRING_ATTRIBUTES = ::Set.new([ :ticket, :reason, :description ])
41
-
42
- # The constructor which takes a hash that represents a JSON request to
43
- # Authlete's /api/auth/authorization/fail API.
44
- def initialize(hash = nil)
45
- # Set default values to string attributes.
46
- STRING_ATTRIBUTES.each do |attr|
47
- send("#{attr}=", nil)
48
- end
49
-
50
- # Set attribute values using the given hash.
51
- authlete_model_update(hash)
31
+ def defaults
32
+ {
33
+ ticket: nil,
34
+ reason: nil,
35
+ description: nil
36
+ }
52
37
  end
53
38
 
54
- def authlete_model_convert_key(key)
55
- key.to_sym
56
- end
57
-
58
- def authlete_model_simple_attribute?(key)
59
- STRING_ATTRIBUTES.include?(key)
60
- end
61
-
62
- def authlete_model_update(hash)
63
- return if hash.nil?
64
-
65
- hash.each do |key, value|
66
- key = authlete_model_convert_key(key)
67
-
68
- if authlete_model_simple_attribute?(key)
69
- send("#{key}=", value)
70
- end
71
- end
72
-
73
- self
74
- end
75
-
76
- public
77
-
78
- # Construct an instance from the given hash.
79
- #
80
- # If the given argument is nil or is not a Hash, nil is returned.
81
- # Otherwise, AuthorizationFailRequest.new(hash) is returned.
82
- def self.parse(hash)
83
- if hash.nil? or (hash.kind_of?(Hash) == false)
84
- return nil
85
- end
86
-
87
- return AuthorizationFailRequest.new(hash)
88
- end
89
-
90
- # Convert this object into a hash.
91
- def to_hash
92
- hash = {}
93
-
94
- instance_variables.each do |var|
95
- key = var.to_s.delete("@").to_sym
96
- val = instance_variable_get(var)
97
-
98
- if authlete_model_simple_attribute?(key) or val.nil?
99
- hash[key] = val
100
- end
101
- end
102
-
103
- hash
39
+ def set_params(hash)
40
+ @ticket = hash[:ticket]
41
+ @reason = hash[:reason]
42
+ @description = hash[:description]
104
43
  end
105
44
  end
106
45
  end
107
46
  end
108
- end
47
+ end
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -15,154 +15,73 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
- require 'set'
19
-
20
-
21
18
  module Authlete
22
19
  module Model
23
20
  module Request
24
- # == Authlete::Model::Request::AuthorizationIssueRequest class
25
- #
26
- # This class represents a request to Authlete's /api/auth/authorization/issue API.
27
- class AuthorizationIssueRequest < Authlete::Model::Hashable
28
- # The ticket issued by Authlete's /api/auth/authorization API. (String)
21
+ class AuthorizationIssueRequest < Authlete::Model::Request::Base
22
+ include Authlete::Utility
23
+
29
24
  attr_accessor :ticket
30
25
 
31
- # The subject (end-user) managed by the service. (String)
32
26
  attr_accessor :subject
33
27
 
34
- # The time when the end-user was authenticated. (Integer)
35
28
  attr_accessor :authTime
36
29
  alias_method :auth_time, :authTime
37
30
  alias_method :auth_time=, :authTime=
38
31
 
39
- # The authentication context class reference. (String)
40
32
  attr_accessor :acr
41
33
 
42
- # Claims in JSON format. (String)
43
34
  attr_accessor :claims
44
35
 
45
- # Extra properties to associate with an access token and/or an
46
- # authorization code. (String)
47
36
  attr_accessor :properties
48
37
 
49
- # Scopes to associate with an access token and/or an authorization code.
50
- # If a non-empty string array is given, it replaces the scopes specified
51
- # by the original authorization request. (String array)
52
38
  attr_accessor :scopes
53
39
 
54
- # The value of the "sub" claim to embed in an ID token. If this request
55
- # parameter is "nil" or empty, the value of the subject request parameter
56
- # is used as the value of the "sub" claim. (String)
57
40
  attr_accessor :sub
58
41
 
59
- private
60
-
61
- # Integer attributes.
62
- INTEGER_ATTRIBUTES = ::Set.new([ :authTime ])
63
-
64
- # String attributes.
65
- STRING_ATTRIBUTES = ::Set.new([ :ticket, :subject, :acr, :claims, :sub ])
66
-
67
- # String array attributes.
68
- STRING_ARRAY_ATTRIBUTES = ::Set.new([ :scopes ])
69
-
70
- # Mapping from snake cases to camel cases.
71
- SNAKE_TO_CAMEL = {
72
- :auth_time => :authTime
73
- }
74
-
75
- # The constructor which takes a hash that represents a JSON request to
76
- # Authlete's /api/auth/authorization/issue API.
77
- def initialize(hash = nil)
78
- # Set default values to integer attributes.
79
- INTEGER_ATTRIBUTES.each do |attr|
80
- send("#{attr}=", 0)
81
- end
82
-
83
- # Set default values to string attributes.
84
- STRING_ATTRIBUTES.each do |attr|
85
- send("#{attr}=", nil)
86
- end
87
-
88
- # Set default values to string array attributes.
89
- STRING_ARRAY_ATTRIBUTES.each do |attr|
90
- send("#{attr}=", nil)
91
- end
92
-
93
- @properties = nil
94
-
95
- # Set attribute values using the given hash.
96
- authlete_model_update(hash)
97
- end
42
+ attr_accessor :idtHeaderParams
43
+ alias_method :idt_header_params, :idtHeaderParams
44
+ alias_method :idt_header_params=, :idtHeaderParams=
98
45
 
99
- def authlete_model_convert_key(key)
100
- key = key.to_sym
101
-
102
- # Convert snakecase to camelcase, if necessary.
103
- if SNAKE_TO_CAMEL.has_key?(key)
104
- key = SNAKE_TO_CAMEL[key]
105
- end
106
-
107
- key
108
- end
109
-
110
- def authlete_model_simple_attribute?(key)
111
- INTEGER_ATTRIBUTES.include?(key) or
112
- STRING_ATTRIBUTES.include?(key) or
113
- STRING_ARRAY_ATTRIBUTES.include?(key)
114
- end
115
-
116
- def authlete_model_update(hash)
117
- return if hash.nil?
118
-
119
- hash.each do |key, value|
120
- key = authlete_model_convert_key(key)
121
-
122
- if authlete_model_simple_attribute?(key)
123
- send("#{key}=", value)
124
- elsif key == :properties
125
- @properties = get_parsed_array(value) do |element|
126
- Authlete::Model::Property.parse(element)
127
- end
128
- end
129
- end
46
+ private
130
47
 
131
- self
48
+ def defaults
49
+ {
50
+ ticket: nil,
51
+ subject: nil,
52
+ authTime: 0,
53
+ acr: nil,
54
+ claims: nil,
55
+ properties: nil,
56
+ scopes: nil,
57
+ sub: nil,
58
+ idtHeaderParams: nil
59
+ }
132
60
  end
133
61
 
134
- public
135
-
136
- # Construct an instance from the given hash.
137
- #
138
- # If the given argument is nil or is not a Hash, nil is returned.
139
- # Otherwise, AuthorizationIssueRequest.new(hash) is returned.
140
- def self.parse(hash)
141
- if hash.nil? or (hash.kind_of?(Hash) == false)
142
- return nil
143
- end
144
-
145
- return AuthorizationIssueRequest.new(hash)
62
+ def set_params(hash)
63
+ @ticket = hash[:ticket]
64
+ @subject = hash[:subject]
65
+ @authTime = hash[:authTime]
66
+ @acr = hash[:acr]
67
+ @claims = hash[:claims]
68
+ @properties = get_parsed_array(hash[:properties]) { |e| Authlete::Model::Property.parse(e) }
69
+ @scopes = hash[:scopes]
70
+ @sub = hash[:sub]
71
+ @idtHeaderParams = hash[:idtHeaderParams]
146
72
  end
147
73
 
148
- # Convert this object into a hash.
149
- def to_hash
150
- hash = {}
74
+ def to_hash_value(key, var)
75
+ raw_val = instance_variable_get(var)
151
76
 
152
- instance_variables.each do |var|
153
- key = var.to_s.delete("@").to_sym
154
- val = instance_variable_get(var)
155
-
156
- if authlete_model_simple_attribute?(key) or val.nil?
157
- hash[key] = val
158
- elsif key == :properties
159
- hash[key] = val.map { |element| element.to_hash }
160
- end
77
+ case key
78
+ when :properties
79
+ raw_val&.map { |e| e.to_hash }
80
+ else
81
+ raw_val
161
82
  end
162
-
163
- hash
164
83
  end
165
84
  end
166
85
  end
167
86
  end
168
- end
87
+ end