authlete 0.2.6 → 0.2.7
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.
- checksums.yaml +4 -4
- data/lib/authlete.rb +1 -0
- data/lib/authlete/api.rb +20 -11
- data/lib/authlete/model/service-owner.rb +174 -0
- data/lib/authlete/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26e057395b00f17652a1c0f8a06bf555ab66ee65
|
4
|
+
data.tar.gz: 72a24185635e85867bfa2fbee55addc05c5ebcc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d34a84d4791e610cfd33cf83627fd8ccba1420864a28ad85fb03478b7f1e1f69d5ccdbd023a5a8c2324b44a3d9408dcac042c5212ce49a36e7252b3fbeb458e
|
7
|
+
data.tar.gz: 038f3f74ac9dea4972df1bfffcba01317d2f4e5527dde914cf6337732fb07777aec2988cdbcc22829b95176b607b9f554940dd8eac150e1102cbad2c52ae06f0
|
data/lib/authlete.rb
CHANGED
@@ -35,6 +35,7 @@ module Authlete
|
|
35
35
|
autoload :Scope, 'authlete/model/scope'
|
36
36
|
autoload :Service, 'authlete/model/service'
|
37
37
|
autoload :ServiceList, 'authlete/model/service-list'
|
38
|
+
autoload :ServiceOwner, 'authlete/model/service-owner'
|
38
39
|
autoload :SnsCredentials, 'authlete/model/sns-credentials'
|
39
40
|
autoload :TaggedValue, 'authlete/model/tagged-value'
|
40
41
|
end
|
data/lib/authlete/api.rb
CHANGED
@@ -226,7 +226,7 @@ module Authlete
|
|
226
226
|
# (which responds to <tt>to_hash</tt>) should be used.
|
227
227
|
#
|
228
228
|
# On success, an instance of Authlete::Model::ServiceList is returned.
|
229
|
-
# On error,
|
229
|
+
# On error, Authlete::Exception is raised.
|
230
230
|
def service_create(service)
|
231
231
|
if service.kind_of?(Hash) == false
|
232
232
|
if service.respond_to?('to_hash')
|
@@ -241,7 +241,7 @@ module Authlete
|
|
241
241
|
|
242
242
|
# Call Authlete's /api/service/delete/{api_key} API.
|
243
243
|
#
|
244
|
-
# On error,
|
244
|
+
# On error, Authlete::Exception is raised.
|
245
245
|
def service_delete(api_key)
|
246
246
|
call_api_service_owner(:delete, "/api/service/delete/#{api_key}", nil, nil)
|
247
247
|
end
|
@@ -253,7 +253,7 @@ module Authlete
|
|
253
253
|
# you want to get.
|
254
254
|
#
|
255
255
|
# On success, an instance of Authlete::Model::Service is returned.
|
256
|
-
# On error,
|
256
|
+
# On error, Authlete::Exception is raised.
|
257
257
|
def service_get(api_key)
|
258
258
|
hash = call_api_service_owner(:get, "/api/service/get/#{api_key}", nil, nil)
|
259
259
|
|
@@ -267,14 +267,13 @@ module Authlete
|
|
267
267
|
# a start index (inclusive) and an end index (exclusive), respectively.
|
268
268
|
#
|
269
269
|
# On success, an instance of Authlete::Model::ServiceList is returned.
|
270
|
-
# On error,
|
270
|
+
# On error, Authlete::Exception is raised.
|
271
271
|
def service_get_list(params = nil)
|
272
272
|
hash = call_api_service_owner(:get, "/api/service/get/list#{to_query(params)}", nil, nil)
|
273
273
|
|
274
274
|
Authlete::Model::ServiceList.new(hash)
|
275
275
|
end
|
276
276
|
|
277
|
-
|
278
277
|
# Call Authlete's /api/service/update/{api_key} API.
|
279
278
|
#
|
280
279
|
# <tt>api_key</tt> is the API key of the service whose information
|
@@ -286,7 +285,7 @@ module Authlete
|
|
286
285
|
# (which responds to <tt>to_hash</tt>) should be used.
|
287
286
|
#
|
288
287
|
# On success, an instance of Authlete::Model::Service is returned.
|
289
|
-
# On error,
|
288
|
+
# On error, Authlete::Exception is raised.
|
290
289
|
def service_update(api_key, service)
|
291
290
|
if service.kind_of?(Hash) == false
|
292
291
|
if service.respond_to?('to_hash')
|
@@ -299,6 +298,16 @@ module Authlete
|
|
299
298
|
Authlete::Model::Service.new(hash)
|
300
299
|
end
|
301
300
|
|
301
|
+
# Call Authlete's /api/serviceowner/get/self API.
|
302
|
+
#
|
303
|
+
# On success, an instance of Authlete::Model::ServiceOwner is returned.
|
304
|
+
# On error, Authlete::Exception is raised.
|
305
|
+
def serviceowner_get_self
|
306
|
+
hash = call_api_json_service_owner(:get, "/api/serviceowner/get/self")
|
307
|
+
|
308
|
+
Authlete::Model::ServiceOwner.new(hash)
|
309
|
+
end
|
310
|
+
|
302
311
|
# Call Authlete's /api/client/create API.
|
303
312
|
#
|
304
313
|
# <tt>client</tt> is the content of a new service to create. The type of
|
@@ -307,7 +316,7 @@ module Authlete
|
|
307
316
|
# (which responds to <tt>to_hash</tt>) should be used.
|
308
317
|
#
|
309
318
|
# On success, an instance of Authlete::Model::ClientList is returned.
|
310
|
-
# On error,
|
319
|
+
# On error, Authlete::Exception is raised.
|
311
320
|
def client_create(client)
|
312
321
|
if client.kind_of?(Hash) == false
|
313
322
|
if client.respond_to?('to_hash')
|
@@ -322,7 +331,7 @@ module Authlete
|
|
322
331
|
|
323
332
|
# Call Authlete's /api/client/delete/{clientId} API.
|
324
333
|
#
|
325
|
-
# On error,
|
334
|
+
# On error, Authlete::Exception is raised.
|
326
335
|
def client_delete(clientId)
|
327
336
|
call_api_service(:delete, "/api/client/delete/#{clientId}", nil, nil)
|
328
337
|
end
|
@@ -330,7 +339,7 @@ module Authlete
|
|
330
339
|
# Call Authlete's /api/client/get/{clientId} API.
|
331
340
|
#
|
332
341
|
# On success, an instance of Authlete::Model::Service is returned.
|
333
|
-
# On error,
|
342
|
+
# On error, Authlete::Exception is raised.
|
334
343
|
def client_get(clientId)
|
335
344
|
hash = call_api_service(:get, "/api/client/get/#{clientId}", nil, nil)
|
336
345
|
|
@@ -344,7 +353,7 @@ module Authlete
|
|
344
353
|
# a start index (inclusive) and an end index (exclusive), respectively.
|
345
354
|
#
|
346
355
|
# On success, an instance of Authlete::Model::ClientList is returned.
|
347
|
-
# On error,
|
356
|
+
# On error, Authlete::Exception is raised.
|
348
357
|
def client_get_list(params = nil)
|
349
358
|
hash = call_api_service(:get, "/api/client/get/list#{to_query(params)}", nil, nil)
|
350
359
|
|
@@ -359,7 +368,7 @@ module Authlete
|
|
359
368
|
# (which responds to <tt>to_hash</tt>) should be used.
|
360
369
|
#
|
361
370
|
# On success, an instance of Authlete::Model::Client is returned.
|
362
|
-
# On error,
|
371
|
+
# On error, Authlete::Exception is raised.
|
363
372
|
def client_update(client)
|
364
373
|
if client.kind_of?(Hash) == false
|
365
374
|
if client.respond_to?('to_hash')
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# :nodoc:
|
2
|
+
#
|
3
|
+
# Copyright (C) 2014-2015 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
|
+
require 'set'
|
19
|
+
|
20
|
+
|
21
|
+
module Authlete
|
22
|
+
module Model
|
23
|
+
class ServiceOwner
|
24
|
+
# The API key of the service owner. (Long)
|
25
|
+
attr_accessor :apiKey
|
26
|
+
alias_method :api_key, :apiKey
|
27
|
+
alias_method :api_key=, :apiKey=
|
28
|
+
|
29
|
+
# The API secret of the service owner. (String)
|
30
|
+
attr_accessor :apiSecret
|
31
|
+
alias_method :api_secret, :apiSecret
|
32
|
+
alias_method :api_secret=, :apiSecret=
|
33
|
+
|
34
|
+
# The email address of the service owner. (String)
|
35
|
+
attr_accessor :email
|
36
|
+
|
37
|
+
# The login ID of the service owner. (String)
|
38
|
+
attr_accessor :loginId
|
39
|
+
alias_method :login_id, :loginId
|
40
|
+
alias_method :login_id=, :loginId=
|
41
|
+
|
42
|
+
# The service owner name. (String)
|
43
|
+
attr_accessor :name
|
44
|
+
|
45
|
+
# The service owner number. (Integer)
|
46
|
+
attr_accessor :number
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# Integer attributes.
|
51
|
+
INTEGER_ATTRIBUTES = ::Set.new([
|
52
|
+
:apiKey, :number
|
53
|
+
])
|
54
|
+
|
55
|
+
# String attributes.
|
56
|
+
STRING_ATTRIBUTES = ::Set.new([
|
57
|
+
:apiSecret, :email, :login_id, :name
|
58
|
+
])
|
59
|
+
|
60
|
+
# Mapping from snake cases to camel cases.
|
61
|
+
SNAKE_TO_CAMEL = {
|
62
|
+
:api_key => :apiKey,
|
63
|
+
:api_secret => :apiSecret,
|
64
|
+
:login_id => :loginId
|
65
|
+
}
|
66
|
+
|
67
|
+
# The constructor
|
68
|
+
def initialize(hash = nil)
|
69
|
+
# Set default values to integer attributes.
|
70
|
+
INTEGER_ATTRIBUTES.each do |attr|
|
71
|
+
send("#{attr}=", 0)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Set default values to string attributes.
|
75
|
+
STRING_ATTRIBUTES.each do |attr|
|
76
|
+
send("#{attr}=", nil)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Set attribute values using the given hash.
|
80
|
+
authlete_model_service_update(hash)
|
81
|
+
end
|
82
|
+
|
83
|
+
def authlete_model_service_to_key(key)
|
84
|
+
key = key.to_sym
|
85
|
+
|
86
|
+
# Convert snakecase to camelcase, if necessary.
|
87
|
+
if SNAKE_TO_CAMEL.has_key?(key)
|
88
|
+
key = SNAKE_TO_CAMEL[key]
|
89
|
+
end
|
90
|
+
|
91
|
+
return key
|
92
|
+
end
|
93
|
+
|
94
|
+
def authlete_model_service_simple_attribute?(key)
|
95
|
+
INTEGER_ATTRIBUTES.include?(key) or
|
96
|
+
STRING_ATTRIBUTES.include?(key)
|
97
|
+
end
|
98
|
+
|
99
|
+
def authlete_model_service_update(hash)
|
100
|
+
if hash.nil?
|
101
|
+
return
|
102
|
+
end
|
103
|
+
|
104
|
+
hash.each do |key, value|
|
105
|
+
key = authlete_model_service_to_key(key)
|
106
|
+
|
107
|
+
# If the attribute is a simple one.
|
108
|
+
if authlete_model_service_simple_attribute?(key)
|
109
|
+
send("#{key}=", value)
|
110
|
+
next
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
return self
|
115
|
+
end
|
116
|
+
|
117
|
+
public
|
118
|
+
|
119
|
+
# Construct an instance from the given hash.
|
120
|
+
#
|
121
|
+
# If the given argument is nil or is not a Hash, nil is returned.
|
122
|
+
# Otherwise, Service.new(hash) is returned.
|
123
|
+
def self.parse(hash)
|
124
|
+
if hash.nil? or (hash.kind_of?(Hash) == false)
|
125
|
+
return nil
|
126
|
+
end
|
127
|
+
|
128
|
+
return Service.new(hash)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Set attribute values using the given hash.
|
132
|
+
def update(hash)
|
133
|
+
authlete_model_service_update(hash)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Convert this object into a hash.
|
137
|
+
def to_hash
|
138
|
+
hash = {}
|
139
|
+
|
140
|
+
instance_variables.each do |var|
|
141
|
+
key = var.to_s.delete("@").to_sym
|
142
|
+
val = instance_variable_get(var)
|
143
|
+
|
144
|
+
if authlete_model_service_simple_attribute?(key) or val.nil?
|
145
|
+
hash[key] = val
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
return hash
|
150
|
+
end
|
151
|
+
|
152
|
+
def [](key)
|
153
|
+
key = authlete_model_service_to_key(key)
|
154
|
+
|
155
|
+
if respond_to?(key)
|
156
|
+
return send(key)
|
157
|
+
else
|
158
|
+
return nil
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def []=(key, value)
|
163
|
+
key = authlete_model_service_to_key(key)
|
164
|
+
method = "#{key}="
|
165
|
+
|
166
|
+
if respond_to?(method)
|
167
|
+
return send(method, value)
|
168
|
+
else
|
169
|
+
return nil
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
data/lib/authlete/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takahiko Kawasaki
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/authlete/model/client.rb
|
76
76
|
- lib/authlete/model/scope.rb
|
77
77
|
- lib/authlete/model/service-list.rb
|
78
|
+
- lib/authlete/model/service-owner.rb
|
78
79
|
- lib/authlete/model/service.rb
|
79
80
|
- lib/authlete/model/sns-credentials.rb
|
80
81
|
- lib/authlete/model/tagged-value.rb
|