authlete 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab0dea663641f59f6f122fb29dcf71efb7f2cec8
4
- data.tar.gz: c54970c03b22d27edaaa072b174a4512e8cf8067
3
+ metadata.gz: 782c3e29ae7af7bae3656c1f297dfac9517fa051
4
+ data.tar.gz: 620fb60d78b1129230ac04c7d2bfc612abc1353b
5
5
  SHA512:
6
- metadata.gz: 20ed509dc656372f88babd36d812969c58e333c08675df697d52bad23802e572be239decbbff89db509cc95b8b6c69390ae83f89a95eb6a056e20b6ed8c00dd6
7
- data.tar.gz: 962d058d75905062b4721d361ea0288483fbb5954c4542a50cd742634d03560a474dc192c91a3036e3f185304954915cbad7b3e76dd4dd2e69e25af00ab707db
6
+ metadata.gz: f6a80980f818568e66c21a70fc27fde43ced88be405b6e17c81c0b355bd01ef6a40b384bcdd2279014e990fc26b3f926a0169bda318e3ec0b40a09108c0a62a3
7
+ data.tar.gz: b1b10886724286e9fb0103ef041e28485f6d79015684f9ca25c275c05872e65a01ccd6b12819839ce9cb066a9e1ee1679835958070de6a9ed817228f5dc02d6a
data/lib/authlete.rb CHANGED
@@ -31,6 +31,7 @@ module Authlete
31
31
  autoload :Hashable, 'authlete/model/hashable'
32
32
  autoload :Client, 'authlete/model/client'
33
33
  autoload :ClientList, 'authlete/model/client-list'
34
+ autoload :ClientExtension, 'authlete/model/client-extension'
34
35
  autoload :Result, 'authlete/model/result'
35
36
  autoload :Scope, 'authlete/model/scope'
36
37
  autoload :Service, 'authlete/model/service'
@@ -0,0 +1,136 @@
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 ClientExtension < Authlete::Model::Hashable
24
+ include Authlete::Utility
25
+
26
+ # The set of scopes that a client application is allowed to request.
27
+ # (String array)
28
+ attr_accessor :requestableScopes
29
+ alias_method :requestable_scopes, :requestableScopes
30
+ alias_method :requestable_scopes=, :requestableScopes=
31
+
32
+ # The flag to show whether a client application can only request
33
+ # the set of scopes that it is allowed to request or it can request
34
+ # all of the scopes that the service supports. (Boolean)
35
+ attr_accessor :requestableScopesEnabled
36
+ alias_method :requestable_scopes_enabled, :requestableScopesEnabled
37
+ alias_method :requestable_scopes_enabled=, :requestableScopesEnabled=
38
+
39
+ private
40
+
41
+ # Boolean attributes.
42
+ BOOLEAN_ATTRIBUTES = ::Set.new([
43
+ :requestableScopesEnabled
44
+ ])
45
+
46
+ # String array attributes.
47
+ STRING_ARRAY_ATTRIBUTES = ::Set.new([
48
+ :requestableScopes
49
+ ])
50
+
51
+ # Mapping from snake cases to camel cases.
52
+ SNAKE_TO_CAMEL = {
53
+ :requestable_scopes => :requestableScopes,
54
+ :requestable_scopes_enabled => :requestableScopesEnabled
55
+ }
56
+
57
+ # The constructor
58
+ def initialize(hash = nil)
59
+ # Set default values to boolean attributes.
60
+ BOOLEAN_ATTRIBUTES.each do |attr|
61
+ send("#{attr}=", false)
62
+ end
63
+
64
+ # Set default values to string array attributes.
65
+ STRING_ARRAY_ATTRIBUTES.each do |attr|
66
+ send("#{attr}=", nil)
67
+ end
68
+
69
+ # Set attribute values using the given hash.
70
+ authlete_model_update(hash)
71
+ end
72
+
73
+ def authlete_model_convert_key(key)
74
+ key = key.to_sym
75
+
76
+ # Convert snakecase to camelcase, if necessary.
77
+ if SNAKE_TO_CAMEL.has_key?(key)
78
+ key = SNAKE_TO_CAMEL[key]
79
+ end
80
+
81
+ key
82
+ end
83
+
84
+ def authlete_model_simple_attribute?(key)
85
+ BOOLEAN_ATTRIBUTES.include?(key) or
86
+ STRING_ARRAY_ATTRIBUTES.include?(key)
87
+ end
88
+
89
+ def authlete_model_update(hash)
90
+ return if hash.nil?
91
+
92
+ hash.each do |key, value|
93
+ key = authlete_model_convert_key(key)
94
+
95
+ if authlete_model_simple_attribute?(key)
96
+ send("#{key}=", value)
97
+ end
98
+ end
99
+
100
+ self
101
+ end
102
+
103
+ public
104
+
105
+ # Construct an instance from the given hash.
106
+ #
107
+ # If the given argument is nil or is not a Hash, nil is returned.
108
+ # Otherwise, ClientList.new(hash) is returned.
109
+ def self.parse(hash)
110
+ if hash.nil? or (hash.kind_of?(Hash) == false)
111
+ return nil
112
+ end
113
+
114
+ return ClientExtension.new(hash)
115
+ end
116
+
117
+ # Convert this object into a hash.
118
+ def to_hash
119
+ hash = {}
120
+
121
+ instance_variables.each do |var|
122
+ key = var.to_s.delete("@").to_sym
123
+ val = instance_variable_get(var)
124
+
125
+ if authlete_model_simple_attribute?(key) or val.nil?
126
+ hash[key] = val
127
+ elsif val.kind_of?(Array)
128
+ hash[key] = val.map { |element| element.to_hash }
129
+ end
130
+ end
131
+
132
+ hash
133
+ end
134
+ end
135
+ end
136
+ end
@@ -260,6 +260,9 @@ module Authlete
260
260
  alias_method :modified_at, :modifiedAt
261
261
  alias_method :modified_at=, :modifiedAt=
262
262
 
263
+ # (ClientExtension)
264
+ attr_accessor :extension
265
+
263
266
  private
264
267
 
265
268
  # Integer attributes.
@@ -360,6 +363,8 @@ module Authlete
360
363
  send("#{attr}=", nil)
361
364
  end
362
365
 
366
+ @extension = nil
367
+
363
368
  # Set attribute values using the given hash.
364
369
  authlete_model_update(hash)
365
370
  end
@@ -397,6 +402,8 @@ module Authlete
397
402
  end
398
403
 
399
404
  send("#{key}=", parsed)
405
+ elsif key == :extension
406
+ @extension = Authlete::Model::ClientExtension.new(value)
400
407
  end
401
408
  end
402
409
 
@@ -434,6 +441,9 @@ module Authlete
434
441
  hash[key] = val
435
442
  elsif val.kind_of?(Array)
436
443
  hash[key] = val.map { |element| element.to_hash }
444
+ else
445
+ # For attributes such as :extension
446
+ hash[key] = val.to_hash
437
447
  end
438
448
  end
439
449
 
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module Authlete
19
- VERSION = "0.4.2"
19
+ VERSION = "0.4.3"
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authlete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiko Kawasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -70,6 +70,7 @@ files:
70
70
  - lib/authlete/api.rb
71
71
  - lib/authlete/authentication-server.rb
72
72
  - lib/authlete/exception.rb
73
+ - lib/authlete/model/client-extension.rb
73
74
  - lib/authlete/model/client-list.rb
74
75
  - lib/authlete/model/client.rb
75
76
  - lib/authlete/model/hashable.rb