authlete 1.0.21 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Makefile +40 -0
  4. data/README.md +20 -20
  5. data/Rakefile +5 -0
  6. data/authlete.gemspec +2 -2
  7. data/lib/authlete.rb +28 -9
  8. data/lib/authlete/api.rb +153 -322
  9. data/lib/authlete/authentication-server.rb +230 -230
  10. data/lib/authlete/exception.rb +14 -15
  11. data/lib/authlete/model/base.rb +30 -0
  12. data/lib/authlete/model/client-extension.rb +17 -119
  13. data/lib/authlete/model/client.rb +203 -338
  14. data/lib/authlete/model/hashable.rb +13 -33
  15. data/lib/authlete/model/named-uri.rb +13 -74
  16. data/lib/authlete/model/pair.rb +13 -74
  17. data/lib/authlete/model/param-initializer.rb +45 -0
  18. data/lib/authlete/model/property.rb +15 -85
  19. data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
  20. data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
  21. data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
  22. data/lib/authlete/model/request/authorization-request.rb +8 -73
  23. data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
  24. data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
  25. data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
  26. data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
  27. data/lib/authlete/model/request/base.rb +26 -0
  28. data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
  29. data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
  30. data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
  31. data/lib/authlete/model/request/client-registration-request.rb +49 -0
  32. data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
  33. data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
  34. data/lib/authlete/model/request/device-authorization-request.rb +63 -0
  35. data/lib/authlete/model/request/device-complete-request.rb +99 -0
  36. data/lib/authlete/model/request/device-verification-request.rb +40 -0
  37. data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
  38. data/lib/authlete/model/request/introspection-request.rb +24 -83
  39. data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
  40. data/lib/authlete/model/request/revocation-request.rb +14 -88
  41. data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
  42. data/lib/authlete/model/request/token-create-request.rb +52 -183
  43. data/lib/authlete/model/request/token-fail-request.rb +12 -74
  44. data/lib/authlete/model/request/token-issue-request.rb +22 -80
  45. data/lib/authlete/model/request/token-request.rb +44 -81
  46. data/lib/authlete/model/request/token-update-request.rb +35 -121
  47. data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
  48. data/lib/authlete/model/request/user-info-request.rb +25 -70
  49. data/lib/authlete/model/response/access-token.rb +96 -0
  50. data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
  51. data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
  52. data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
  53. data/lib/authlete/model/response/authorization-response.rb +97 -123
  54. data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
  55. data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
  56. data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
  57. data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
  58. data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
  59. data/lib/authlete/model/response/client-list-response.rb +58 -0
  60. data/lib/authlete/model/response/client-registration-response.rb +50 -0
  61. data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
  62. data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
  63. data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
  64. data/lib/authlete/model/response/device-authorization-response.rb +134 -0
  65. data/lib/authlete/model/response/device-complete-response.rb +39 -0
  66. data/lib/authlete/model/response/device-verification-response.rb +96 -0
  67. data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
  68. data/lib/authlete/model/response/introspection-response.rb +64 -58
  69. data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
  70. data/lib/authlete/model/response/revocation-response.rb +12 -15
  71. data/lib/authlete/model/response/service-list-response.rb +54 -0
  72. data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
  73. data/lib/authlete/model/response/token-create-response.rb +50 -55
  74. data/lib/authlete/model/response/token-fail-response.rb +14 -17
  75. data/lib/authlete/model/response/token-issue-response.rb +49 -62
  76. data/lib/authlete/model/response/token-list-response.rb +64 -0
  77. data/lib/authlete/model/response/token-response.rb +59 -79
  78. data/lib/authlete/model/response/token-update-response.rb +28 -23
  79. data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
  80. data/lib/authlete/model/response/user-info-response.rb +48 -42
  81. data/lib/authlete/model/result.rb +14 -13
  82. data/lib/authlete/model/scope.rb +68 -158
  83. data/lib/authlete/model/service-owner.rb +32 -116
  84. data/lib/authlete/model/service.rb +672 -837
  85. data/lib/authlete/model/sns-credentials.rb +51 -124
  86. data/lib/authlete/model/tagged-value.rb +14 -69
  87. data/lib/authlete/utility.rb +70 -99
  88. data/lib/authlete/version.rb +3 -3
  89. data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
  90. data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
  91. data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
  92. data/test/authlete/model/request/test_authorization-request.rb +57 -0
  93. data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
  94. data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
  95. data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
  96. data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
  97. data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
  98. data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
  99. data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
  100. data/test/authlete/model/request/test_client-registration-request.rb +68 -0
  101. data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
  102. data/test/authlete/model/request/test_device-complete-request.rb +102 -0
  103. data/test/authlete/model/request/test_device-verification-request.rb +57 -0
  104. data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
  105. data/test/authlete/model/request/test_introspection-request.rb +79 -0
  106. data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
  107. data/test/authlete/model/request/test_revocation-request.rb +67 -0
  108. data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
  109. data/test/authlete/model/request/test_token-create-request.rb +110 -0
  110. data/test/authlete/model/request/test_token-fail-request.rb +63 -0
  111. data/test/authlete/model/request/test_token-issue-request.rb +70 -0
  112. data/test/authlete/model/request/test_token-request.rb +94 -0
  113. data/test/authlete/model/request/test_token-update-request.rb +82 -0
  114. data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
  115. data/test/authlete/model/request/test_user-info-request.rb +75 -0
  116. data/test/authlete/model/response/test_access-token.rb +101 -0
  117. data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
  118. data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
  119. data/test/authlete/model/response/test_authorization-response.rb +145 -0
  120. data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
  121. data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
  122. data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
  123. data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
  124. data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
  125. data/test/authlete/model/response/test_client-list-response.rb +79 -0
  126. data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
  127. data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
  128. data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
  129. data/test/authlete/model/response/test_device-complete-response.rb +64 -0
  130. data/test/authlete/model/response/test_device-verification-response.rb +112 -0
  131. data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
  132. data/test/authlete/model/response/test_introspection-response.rb +127 -0
  133. data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
  134. data/test/authlete/model/response/test_revocation-response.rb +68 -0
  135. data/test/authlete/model/response/test_service-list-response.rb +72 -0
  136. data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
  137. data/test/authlete/model/response/test_token-create-response.rb +107 -0
  138. data/test/authlete/model/response/test_token-fail-response.rb +68 -0
  139. data/test/authlete/model/response/test_token-issue-response.rb +127 -0
  140. data/test/authlete/model/response/test_token-list-response.rb +84 -0
  141. data/test/authlete/model/response/test_token-response.rb +147 -0
  142. data/test/authlete/model/response/test_token-update-response.rb +87 -0
  143. data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
  144. data/test/authlete/model/response/test_user-info-response.rb +107 -0
  145. data/test/authlete/model/test_client-extension.rb +95 -0
  146. data/test/authlete/model/test_client.rb +461 -0
  147. data/test/authlete/model/test_named-uri.rb +85 -0
  148. data/test/authlete/model/test_pair.rb +85 -0
  149. data/test/authlete/model/test_property.rb +90 -0
  150. data/test/authlete/model/test_result.rb +68 -0
  151. data/test/authlete/model/test_scope.rb +106 -0
  152. data/test/authlete/model/test_service-owner.rb +80 -0
  153. data/test/authlete/model/test_service.rb +624 -0
  154. data/test/authlete/model/test_sns-credentials.rb +88 -0
  155. data/test/authlete/model/test_tagged-value.rb +83 -0
  156. data/test/authlete/test_exception.rb +70 -0
  157. metadata +173 -13
  158. data/lib/authlete/model/client-list.rb +0 -129
  159. data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
  160. data/lib/authlete/model/response/service-creatable-response.rb +0 -51
  161. 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,109 +15,37 @@
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::ClientAuthorizationGetListRequest class
25
- #
26
- # This class represents a request to Authlete's /api/client/authorization/get/list API.
27
- class ClientAuthorizationGetListRequest < Authlete::Model::Hashable
21
+ class ClientAuthorizationGetListRequest < Authlete::Model::Request::Base
28
22
 
29
- # Unique user ID. (String)
30
23
  attr_accessor :subject
31
24
 
32
- # Start index of search results (inclusive).
33
- # (Integer)
25
+ attr_accessor :developer
26
+
34
27
  attr_accessor :start
35
28
 
36
- # End index of search results (exclusive).
37
- # (Integer)
38
29
  attr_accessor :end
39
30
 
40
- # Unique Developer ID. (String)
41
- attr_accessor :developer
42
-
43
31
  private
44
32
 
45
- # Integer attributes.
46
- INTEGER_ATTRIBUTES = ::Set.new([ :start, :end ])
47
-
48
- # String attributes.
49
- STRING_ATTRIBUTES = ::Set.new([ :subject, :developer ])
50
-
51
- # The constructor which takes a hash that represents a JSON request
52
- # to Authlete's /api/client/authorization/get/list API.
53
- def initialize(hash = nil)
54
- # Set default values to integer attributes.
55
- INTEGER_ATTRIBUTES.each do |attr|
56
- send("#{attr}=", 0)
57
- end
58
-
59
- # Set default values to string attributes.
60
- STRING_ATTRIBUTES.each do |attr|
61
- send("#{attr}=", nil)
62
- end
63
-
64
- # Set attribute values using the given hash.
65
- authlete_model_update(hash)
66
- end
67
-
68
- def authlete_model_convert_key(key)
69
- key.to_sym
70
- end
71
-
72
- def authlete_model_simple_attribute?(key)
73
- INTEGER_ATTRIBUTES.include?(key) or
74
- STRING_ATTRIBUTES.include?(key)
33
+ def defaults
34
+ {
35
+ subject: nil,
36
+ developer: nil,
37
+ start: 0,
38
+ end: 0
39
+ }
75
40
  end
76
41
 
77
- def authlete_model_update(hash)
78
- return if hash.nil?
79
-
80
- hash.each do |key, value|
81
- key = authlete_model_convert_key(key)
82
-
83
- if authlete_model_simple_attribute?(key)
84
- send("#{key}=", value)
85
- end
86
- end
87
-
88
- self
89
- end
90
-
91
- public
92
-
93
- # Construct an instance from the given hash.
94
- #
95
- # If the given argument is nil or is not a Hash, nil is returned.
96
- # Otherwise, ClientAuthorizationGetListRequest.new(hash) is returned.
97
- def self.parse(hash)
98
- if hash.nil? or (hash.kind_of?(Hash) == false)
99
- return nil
100
- end
101
-
102
- return ClientAuthorizationGetListRequest.new(hash)
103
- end
104
-
105
- # Convert this object into a hash.
106
- def to_hash
107
- hash = {}
108
-
109
- instance_variables.each do |var|
110
- key = var.to_s.delete("@").to_sym
111
- val = instance_variable_get(var)
112
-
113
- if authlete_model_simple_attribute?(key) or val.nil?
114
- hash[key] = val
115
- end
116
- end
117
-
118
- hash
42
+ def set_params(hash)
43
+ @subject = hash[:subject]
44
+ @developer = hash[:developer]
45
+ @start = hash[:start]
46
+ @end = hash[:end]
119
47
  end
120
48
  end
121
49
  end
122
50
  end
123
- end
51
+ 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,104 +15,29 @@
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::ClientAuthorizationUpdateRequest class
25
- #
26
- # This class represents a request to Authlete's /api/client/authorization/update API.
27
- class ClientAuthorizationUpdateRequest < Authlete::Model::Hashable
21
+ class ClientAuthorizationUpdateRequest < Authlete::Model::Request::Base
28
22
 
29
- # Unique user ID. (String)
30
23
  attr_accessor :subject
31
24
 
32
- # The new value of scopes that is set to existing access tokens.
33
- # "nil" means that scopes are not changed. (String array)
34
25
  attr_accessor :scopes
35
26
 
36
27
  private
37
28
 
38
- # String attributes.
39
- STRING_ATTRIBUTES = ::Set.new([ :subject ])
40
-
41
- # String array attributes.
42
- STRING_ARRAY_ATTRIBUTES = ::Set.new([ :scopes ])
43
-
44
- # The constructor which takes a hash that represents a JSON request
45
- # to Authlete's /api/client/authorization/update API.
46
- def initialize(hash = nil)
47
- # Set default values to string attributes.
48
- STRING_ATTRIBUTES.each do |attr|
49
- send("#{attr}=", nil)
50
- end
51
-
52
- # Set default values to string array attributes.
53
- STRING_ARRAY_ATTRIBUTES.each do |attr|
54
- send("#{attr}=", nil)
55
- end
56
-
57
- # Set attribute values using the given hash.
58
- authlete_model_update(hash)
59
- end
60
-
61
- def authlete_model_convert_key(key)
62
- key.to_sym
63
- end
64
-
65
- def authlete_model_simple_attribute?(key)
66
- STRING_ATTRIBUTES.include?(key) or
67
- STRING_ARRAY_ATTRIBUTES.include?(key)
68
- end
69
-
70
- def authlete_model_update(hash)
71
- return if hash.nil?
72
-
73
- hash.each do |key, value|
74
- key = authlete_model_convert_key(key)
75
-
76
- if authlete_model_simple_attribute?(key)
77
- send("#{key}=", value)
78
- end
79
- end
80
-
81
- self
29
+ def defaults
30
+ {
31
+ subject: nil,
32
+ scopes: nil
33
+ }
82
34
  end
83
35
 
84
- public
85
-
86
- # Construct an instance from the given hash.
87
- #
88
- # If the given argument is nil or is not a Hash, nil is returned.
89
- # Otherwise, ClientAuthorizationUpdateRequest.new(hash) is returned.
90
- def self.parse(hash)
91
- if hash.nil? or (hash.kind_of?(Hash) == false)
92
- return nil
93
- end
94
-
95
- return ClientAuthorizationUpdateRequest.new(hash)
96
- end
97
-
98
- # Convert this object into a hash.
99
- def to_hash
100
- hash = {}
101
-
102
- instance_variables.each do |var|
103
- key = var.to_s.delete("@").to_sym
104
- val = instance_variable_get(var)
105
-
106
- if authlete_model_simple_attribute?(key) or val.nil?
107
- hash[key] = val
108
- elsif val.kind_of?(Array)
109
- hash[key] = val.map { |element| element.to_hash }
110
- end
111
- end
112
-
113
- hash
36
+ def set_params(hash)
37
+ @subject = hash[:subject]
38
+ @scopes = hash[:scopes]
114
39
  end
115
40
  end
116
41
  end
117
42
  end
118
- end
43
+ end
@@ -0,0 +1,49 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Authlete
19
+ module Model
20
+ module Request
21
+ class ClientRegistrationRequest < Authlete::Model::Request::Base
22
+
23
+ attr_accessor :json
24
+
25
+ attr_accessor :token
26
+
27
+ attr_accessor :clientId
28
+ alias_method :client_id, :clientId
29
+ alias_method :client_id=, :clientId=
30
+
31
+ private
32
+
33
+ def defaults
34
+ {
35
+ json: nil,
36
+ token: nil,
37
+ clientId: nil
38
+ }
39
+ end
40
+
41
+ def set_params(hash)
42
+ @json = hash[:json]
43
+ @token = hash[:token]
44
+ @clientId = hash[:clientId]
45
+ end
46
+ end
47
+ end
48
+ end
49
+ 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,107 +15,25 @@
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::ClientSecretUpdateRequest class
25
- #
26
- # This class represents a request to Authlete's /api/client/secret/update/{clientIdentifier} API.
27
- class ClientSecretUpdateRequest < Authlete::Model::Hashable
21
+ class ClientSecretUpdateRequest < Authlete::Model::Request::Base
28
22
 
29
- # Client secret. (String)
30
- #
31
- # The new value of the client secret. Valid characters for a client
32
- # secret are A-Z, a-z, 0-9, -, and _. The maximum length of a client
33
- # secret is 86.
34
23
  attr_accessor :clientSecret
35
24
  alias_method :client_secret, :clientSecret
36
25
  alias_method :client_secret=, :clientSecret=
37
26
 
38
27
  private
39
28
 
40
- # String attributes.
41
- STRING_ATTRIBUTES = ::Set.new([ :clientSecret ])
42
-
43
- # Mapping from snake cases to camel cases.
44
- SNAKE_TO_CAMEL = {
45
- :client_secret => :clientSecret
46
- }
47
-
48
- # The constructor which takes a hash that represents a JSON request
49
- # to Authlete's /api/client/secret/update/{clientIdentifier} API.
50
- def initialize(hash = nil)
51
- # Set default values to string attributes.
52
- STRING_ATTRIBUTES.each do |attr|
53
- send("#{attr}=", nil)
54
- end
55
-
56
- # Set attribute values using the given hash.
57
- authlete_model_update(hash)
58
- end
59
-
60
- def authlete_model_convert_key(key)
61
- key = key.to_sym
62
-
63
- # Convert snakecase to camelcase, if necessary.
64
- if SNAKE_TO_CAMEL.has_key?(key)
65
- key = SNAKE_TO_CAMEL[key]
66
- end
67
-
68
- key
29
+ def defaults
30
+ { clientSecret: nil }
69
31
  end
70
32
 
71
- def authlete_model_simple_attribute?(key)
72
- STRING_ATTRIBUTES.include?(key)
73
- end
74
-
75
- def authlete_model_update(hash)
76
- return if hash.nil?
77
-
78
- hash.each do |key, value|
79
- key = authlete_model_convert_key(key)
80
-
81
- if authlete_model_simple_attribute?(key)
82
- send("#{key}=", value)
83
- end
84
- end
85
-
86
- self
87
- end
88
-
89
- public
90
-
91
- # Construct an instance from the given hash.
92
- #
93
- # If the given argument is nil or is not a Hash, nil is returned.
94
- # Otherwise, ClientSecretUpdateRequest.new(hash) is returned.
95
- def self.parse(hash)
96
- if hash.nil? or (hash.kind_of?(Hash) == false)
97
- return nil
98
- end
99
-
100
- return ClientSecretUpdateRequest.new(hash)
101
- end
102
-
103
- # Convert this object into a hash.
104
- def to_hash
105
- hash = {}
106
-
107
- instance_variables.each do |var|
108
- key = var.to_s.delete("@").to_sym
109
- val = instance_variable_get(var)
110
-
111
- if authlete_model_simple_attribute?(key) or val.nil?
112
- hash[key] = val
113
- end
114
- end
115
-
116
- hash
33
+ def set_params(hash)
34
+ @clientSecret = hash[:clientSecret]
117
35
  end
118
36
  end
119
37
  end
120
38
  end
121
- end
39
+ 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,62 +15,59 @@
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::DeveloperAuthenticationCallbackRequest class
25
- #
26
- # This class represents a request to a developer authentication callback endpoint.
27
21
  class DeveloperAuthenticationCallbackRequest
28
- include Authlete::Utility
29
- # The API key of the service.
30
- attr_accessor :service_api_key
31
22
 
32
- # The login ID that the developer input to the login ID field.
33
- # When 'sns' attribute is not nil, this attribute holds the
34
- # subject (= unique identifier) of the developer in the SNS.
23
+ attr_accessor :serviceApiKey
24
+ alias_method :service_api_key, :serviceApiKey
25
+ alias_method :service_api_key=, :serviceApiKey=
26
+
35
27
  attr_accessor :id
36
28
 
37
- # The password that the developer input to the password field.
38
- # If 'sns' property is nil, it is ensured that this attribute
39
- # is not nil. In such a case, authentication should be performed
40
- # on the pair of 'id' attribute and this 'password' attribute.
41
- # On the other hand, if 'sns' attribute is not nil, this attribute
42
- # has no meaning, because authentication has performed by the SNS.
43
29
  attr_accessor :password
44
30
 
45
- # The SNS which the developer used for social login.
46
- # For example, 'FACEBOOK'.
47
31
  attr_accessor :sns
48
32
 
49
- # The access token issued at the token endpoint of the SNS.
50
- attr_accessor :access_token
33
+ attr_accessor :accessToken
34
+ alias_method :access_token, :accessToken
35
+ alias_method :access_token=, :accessToken=
51
36
 
52
- # The refresh token issued along with the access token.
53
- attr_accessor :refresh_token
37
+ attr_accessor :refreshToken
38
+ alias_method :refresh_token, :refreshToken
39
+ alias_method :refresh_token=, :refreshToken=
54
40
 
55
- # The duration of the access token.
56
- attr_accessor :expires_in
41
+ attr_accessor :expiresIn
42
+ alias_method :expires_in, :expiresIn
43
+ alias_method :expires_in=, :expiresIn=
57
44
 
58
- # The raw content of the response from the token endpoint of the SNS.
59
- # Correct OAuth 2.0 implementations return 'application/json', but
60
- # Facebook returns 'application/x-www-form-url-encoded'.
61
- attr_accessor :raw_token_response
45
+ attr_accessor :rawTokenResponse
46
+ alias_method :raw_token_response, :rawTokenResponse
47
+ alias_method :raw_token_response=, :rawTokenResponse=
48
+
49
+ def defaults
50
+ {
51
+ serviceApiKey: nil,
52
+ id: nil,
53
+ password: nil,
54
+ sns: nil,
55
+ accessToken: nil,
56
+ refreshToken: nil,
57
+ expiresIn: 0,
58
+ rawTokenResponse: nil
59
+ }
60
+ end
62
61
 
63
- # The constructor which takes a hash that represents a JSON request
64
- # to a developer authentication callback endpoint.
65
- def initialize(hash = {})
66
- @service_api_key = extract_value(hash, :serviceApiKey)
67
- @id = extract_value(hash, :id)
68
- @password = extract_value(hash, :password)
69
- @sns = extract_value(hash, :sns)
70
- @access_token = extract_value(hash, :accessToken)
71
- @refresh_token = extract_value(hash, :refreshToken)
72
- @expires_in = extract_integer_value(hash, :expiresIn)
73
- @raw_token_response = extract_value(hash, :rawTokenResponse)
62
+ def set_params(hash)
63
+ @serviceApiKey = hash[:serviceApiKey]
64
+ @id = hash[:id]
65
+ @password = hash[:password]
66
+ @sns = hash[:sns]
67
+ @accessToken = hash[:accessToken]
68
+ @refreshToken = hash[:refreshToken]
69
+ @expiresIn = hash[:expiresIn]
70
+ @rawTokenResponse = hash[:rawTokenResponse]
74
71
  end
75
72
 
76
73
  # Parse a JSON string which represents a request to a developer
@@ -82,4 +79,4 @@ module Authlete
82
79
  end
83
80
  end
84
81
  end
85
- end
82
+ end