authlete 0.0.9 → 0.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.
- checksums.yaml +8 -8
 - data/lib/authlete/model/scope.rb +83 -0
 - data/lib/authlete/model/service.rb +148 -0
 - data/lib/authlete/model/sns-credentials.rb +74 -0
 - data/lib/authlete/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            !binary "U0hBMQ==":
         
     | 
| 
       3 
3 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
                NTI0YTA3NTliYjQ5YWI3Mzg2OGYxMTY5NDAzMjgyN2U4NDYyY2VkMA==
         
     | 
| 
       5 
5 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                NmMwYTFlOTI1MTIyYzhhMzIyMTcwZmRiZmYzM2ZmMjk0ZGQ5OGE3ZA==
         
     | 
| 
       7 
7 
     | 
    
         
             
            SHA512:
         
     | 
| 
       8 
8 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                NDQ2NTU2ODBlZTM1YWI5MjQzYjk2NWNhZjA3Y2Y4ZDdhN2I3M2E1ZjA0Y2Uw
         
     | 
| 
      
 10 
     | 
    
         
            +
                NzkzNWRlZjZhYjdkNjgyY2UxMzMyNjk3YmEyMjRkNjMzM2U1MDA5ZjE3ZWJm
         
     | 
| 
      
 11 
     | 
    
         
            +
                YzUwMjc0NTBjMjI3OTBhYzMwODZiNGYxNDdhNGFiOGY4YmI0ZmQ=
         
     | 
| 
       12 
12 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                MTQ5NDIxZWEwNWM3NjBmMzIwOThmNjU0MWNiMDBlOGI0YWIxMDc5ZDM2ZjQ5
         
     | 
| 
      
 14 
     | 
    
         
            +
                YTQ1ZDc5MmI0YzY5ZmVkZWMzYmE3OTJmZDk5NTI5OWJmZjg5ODMyNGEyZTQ4
         
     | 
| 
      
 15 
     | 
    
         
            +
                MzkxZmY4NzExZWJiZDI1YTk4MDlmYTAzYjYwYjY3M2ZlNWY0MGE=
         
     | 
    
        data/lib/authlete/model/scope.rb
    CHANGED
    
    | 
         @@ -15,6 +15,9 @@ 
     | 
|
| 
       15 
15 
     | 
    
         
             
            # limitations under the License.
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
            require 'set'
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       18 
21 
     | 
    
         
             
            module Authlete
         
     | 
| 
       19 
22 
     | 
    
         
             
              module Model
         
     | 
| 
       20 
23 
     | 
    
         
             
                class Scope
         
     | 
| 
         @@ -27,6 +30,86 @@ module Authlete 
     | 
|
| 
       27 
30 
     | 
    
         
             
                  # The flag to indicate whether this scope is included in the
         
     | 
| 
       28 
31 
     | 
    
         
             
                  # default scope set. (boolean)
         
     | 
| 
       29 
32 
     | 
    
         
             
                  attr_accessor :defaultEntry
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  private
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  # Boolean attributes.
         
     | 
| 
      
 37 
     | 
    
         
            +
                  BOOLEAN_ATTRIBUTES = ::Set.new([:defaultEntry])
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  # String attributes.
         
     | 
| 
      
 40 
     | 
    
         
            +
                  STRING_ATTRIBUTES = ::Set.new([:description, :name])
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  # The constructor
         
     | 
| 
      
 43 
     | 
    
         
            +
                  def initialize(hash = new)
         
     | 
| 
      
 44 
     | 
    
         
            +
                    # Set default values to boolean attributes.
         
     | 
| 
      
 45 
     | 
    
         
            +
                    BOOLEAN_ATTRIBUTES.each do |attr|
         
     | 
| 
      
 46 
     | 
    
         
            +
                      send("#{attr}=", false)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    # Set default values to string attributes.
         
     | 
| 
      
 50 
     | 
    
         
            +
                    STRING_ATTRIBUTES.each do |attr|
         
     | 
| 
      
 51 
     | 
    
         
            +
                      send("#{attr}=", nil)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    # Set attribute values using the given hash.
         
     | 
| 
      
 55 
     | 
    
         
            +
                    authlete_model_scope_update(hash)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  def authlete_model_scope_simple_attribute?(key)
         
     | 
| 
      
 59 
     | 
    
         
            +
                    BOOLEAN_ATTRIBUTES.include?(key) or
         
     | 
| 
      
 60 
     | 
    
         
            +
                    STRING_ATTRIBUTES.include?(key)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  def authlete_model_scope_update(hash)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    if hash.nil?
         
     | 
| 
      
 65 
     | 
    
         
            +
                      return
         
     | 
| 
      
 66 
     | 
    
         
            +
                    end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                    hash.each do |key, value|
         
     | 
| 
      
 69 
     | 
    
         
            +
                      key = key.to_sym
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                      # If the attribute is a simple one.
         
     | 
| 
      
 72 
     | 
    
         
            +
                      if authlete_model_scope_simple_attribute?(key)
         
     | 
| 
      
 73 
     | 
    
         
            +
                        send("#{key}=", value)
         
     | 
| 
      
 74 
     | 
    
         
            +
                        next
         
     | 
| 
      
 75 
     | 
    
         
            +
                      end
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                    return self
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  public
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                  # Construct an instance from the given hash.
         
     | 
| 
      
 84 
     | 
    
         
            +
                  #
         
     | 
| 
      
 85 
     | 
    
         
            +
                  # If the given argument is nil or is not a Hash, nil is returned.
         
     | 
| 
      
 86 
     | 
    
         
            +
                  # Otherwise, Scope.new(hash) is returned.
         
     | 
| 
      
 87 
     | 
    
         
            +
                  def self.parse(hash)
         
     | 
| 
      
 88 
     | 
    
         
            +
                    if hash.nil? or (hash.kind_of?(Hash) == false)
         
     | 
| 
      
 89 
     | 
    
         
            +
                      return nil
         
     | 
| 
      
 90 
     | 
    
         
            +
                    end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                    return Authlete::Model::Scope.new(hash)
         
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                  # Set attribute values using the given hash.
         
     | 
| 
      
 96 
     | 
    
         
            +
                  def update(hash)
         
     | 
| 
      
 97 
     | 
    
         
            +
                    authlete_model_scope_update(hash)
         
     | 
| 
      
 98 
     | 
    
         
            +
                  end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                  # Convert this object into a hash.
         
     | 
| 
      
 101 
     | 
    
         
            +
                  def to_hash
         
     | 
| 
      
 102 
     | 
    
         
            +
                    hash = {}
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    instance_variables.each do |var|
         
     | 
| 
      
 105 
     | 
    
         
            +
                      key = var.to_s.delete("@").to_sym
         
     | 
| 
      
 106 
     | 
    
         
            +
                      val = instance_variable_get(var)
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                      hash[key] = val
         
     | 
| 
      
 109 
     | 
    
         
            +
                    end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                    return hash
         
     | 
| 
      
 112 
     | 
    
         
            +
                  end
         
     | 
| 
       30 
113 
     | 
    
         
             
                end
         
     | 
| 
       31 
114 
     | 
    
         
             
              end
         
     | 
| 
       32 
115 
     | 
    
         
             
            end
         
     | 
| 
         @@ -15,6 +15,9 @@ 
     | 
|
| 
       15 
15 
     | 
    
         
             
            # limitations under the License.
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
            require 'set'
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       18 
21 
     | 
    
         
             
            module Authlete
         
     | 
| 
       19 
22 
     | 
    
         
             
              module Model
         
     | 
| 
       20 
23 
     | 
    
         
             
                class Service
         
     | 
| 
         @@ -136,6 +139,151 @@ module Authlete 
     | 
|
| 
       136 
139 
     | 
    
         | 
| 
       137 
140 
     | 
    
         
             
                  # The URI of UserInfo endpoint. (URI)
         
     | 
| 
       138 
141 
     | 
    
         
             
                  attr_accessor :userInfoEndpoint
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                  private
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                  # Integer attributes.
         
     | 
| 
      
 146 
     | 
    
         
            +
                  INTEGER_ATTRIBUTES = ::Set.new([
         
     | 
| 
      
 147 
     | 
    
         
            +
                    :accessTokenDuration, :apiKey, :idTokenDuration, :number,
         
     | 
| 
      
 148 
     | 
    
         
            +
                    :refreshTokenDuration, :serviceOwnerNumber
         
     | 
| 
      
 149 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                  # String attributes.
         
     | 
| 
      
 152 
     | 
    
         
            +
                  STRING_ATTRIBUTES = ::Set.new([
         
     | 
| 
      
 153 
     | 
    
         
            +
                    :accessTokenType, :apiSecret, :authenticationCallbackApiKey,
         
     | 
| 
      
 154 
     | 
    
         
            +
                    :authenticationCallbackApiSecret, :authenticationCallbackEndpoint,
         
     | 
| 
      
 155 
     | 
    
         
            +
                    :authorizationEndpoint, :description, :issuer, :jwks, :jwksUri,
         
     | 
| 
      
 156 
     | 
    
         
            +
                    :policyUri, :registrationEndpoint, :serviceDocumentation,
         
     | 
| 
      
 157 
     | 
    
         
            +
                    :serviceName, :tokenEndpoint, :tosUri, :userInfoEndpoint
         
     | 
| 
      
 158 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                  # String array attributes.
         
     | 
| 
      
 161 
     | 
    
         
            +
                  STRING_ARRAY_ATTRIBUTES = ::Set.new([
         
     | 
| 
      
 162 
     | 
    
         
            +
                    :supportedAcrs, :supportedClaimLocales, :supportedClaims,
         
     | 
| 
      
 163 
     | 
    
         
            +
                    :supportedClaimTypes, :supportedDisplays, :supportedGrantTypes,
         
     | 
| 
      
 164 
     | 
    
         
            +
                    :supportedResponseTypes, :supportedSnses, :supportedTokenAuthMethods,
         
     | 
| 
      
 165 
     | 
    
         
            +
                    :supportedUiLocales
         
     | 
| 
      
 166 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                  # The constructor
         
     | 
| 
      
 169 
     | 
    
         
            +
                  def initialize(hash = nil)
         
     | 
| 
      
 170 
     | 
    
         
            +
                    # Set default values to integer attributes.
         
     | 
| 
      
 171 
     | 
    
         
            +
                    INTEGER_ATTRIBUTES.each do |attr|
         
     | 
| 
      
 172 
     | 
    
         
            +
                      send("#{attr}=", 0)
         
     | 
| 
      
 173 
     | 
    
         
            +
                    end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                    # Set default values to string attributes.
         
     | 
| 
      
 176 
     | 
    
         
            +
                    STRING_ATTRIBUTES.each do |attr|
         
     | 
| 
      
 177 
     | 
    
         
            +
                      send("#{attr}=", nil)
         
     | 
| 
      
 178 
     | 
    
         
            +
                    end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                    # Set default values to string array attributes.
         
     | 
| 
      
 181 
     | 
    
         
            +
                    STRING_ARRAY_ATTRIBUTES.each do |attr|
         
     | 
| 
      
 182 
     | 
    
         
            +
                      send("#{attr}=", nil)
         
     | 
| 
      
 183 
     | 
    
         
            +
                    end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                    # Set default values to special objects.
         
     | 
| 
      
 186 
     | 
    
         
            +
                    @snsCredentials  = nil
         
     | 
| 
      
 187 
     | 
    
         
            +
                    @supportedScopes = nil
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                    # Set attribute values using the given hash.
         
     | 
| 
      
 190 
     | 
    
         
            +
                    authlete_model_service_update(hash)
         
     | 
| 
      
 191 
     | 
    
         
            +
                  end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                  def authlete_model_service_simple_attribute?(key)
         
     | 
| 
      
 194 
     | 
    
         
            +
                    INTEGER_ATTRIBUTES.include?(key) or
         
     | 
| 
      
 195 
     | 
    
         
            +
                    STRING_ATTRIBUTES.include?(key) or
         
     | 
| 
      
 196 
     | 
    
         
            +
                    STRING_ARRAY_ATTRIBUTES.include?(key)
         
     | 
| 
      
 197 
     | 
    
         
            +
                  end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                  def authlete_model_service_update(hash)
         
     | 
| 
      
 200 
     | 
    
         
            +
                    if hash.nil?
         
     | 
| 
      
 201 
     | 
    
         
            +
                      return
         
     | 
| 
      
 202 
     | 
    
         
            +
                    end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
                    hash.each do |key, value|
         
     | 
| 
      
 205 
     | 
    
         
            +
                      key = key.to_sym
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                      # If the attribute is a simple one.
         
     | 
| 
      
 208 
     | 
    
         
            +
                      if authlete_model_service_simple_attribute?(key)
         
     | 
| 
      
 209 
     | 
    
         
            +
                        send("#{key}=", value)
         
     | 
| 
      
 210 
     | 
    
         
            +
                        next
         
     | 
| 
      
 211 
     | 
    
         
            +
                      end
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                      if key == :snsCredentials
         
     | 
| 
      
 214 
     | 
    
         
            +
                        # The attribute 'snsCredentials'.
         
     | 
| 
      
 215 
     | 
    
         
            +
                        @snsCredentials = authlete_model_service_parse_array(value) do |element|
         
     | 
| 
      
 216 
     | 
    
         
            +
                          Authlete::Model::SnsCredentials.parse(element)
         
     | 
| 
      
 217 
     | 
    
         
            +
                        end
         
     | 
| 
      
 218 
     | 
    
         
            +
                      elsif key == :supportedScopes
         
     | 
| 
      
 219 
     | 
    
         
            +
                        # The attribute 'supportedScopes'.
         
     | 
| 
      
 220 
     | 
    
         
            +
                        @supportedScopes = authlete_model_service_parse_array(value) do |element|
         
     | 
| 
      
 221 
     | 
    
         
            +
                          Authlete::Model::Scope.parse(element)
         
     | 
| 
      
 222 
     | 
    
         
            +
                        end
         
     | 
| 
      
 223 
     | 
    
         
            +
                      end
         
     | 
| 
      
 224 
     | 
    
         
            +
                    end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                    return self
         
     | 
| 
      
 227 
     | 
    
         
            +
                  end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                  def authlete_model_service_parse_array(array)
         
     | 
| 
      
 230 
     | 
    
         
            +
                    if array.nil? or (array.kind_of?(Array) == false) or (array.length == 0)
         
     | 
| 
      
 231 
     | 
    
         
            +
                      return nil
         
     | 
| 
      
 232 
     | 
    
         
            +
                    end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
                    elements = []
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                    array.each do |element|
         
     | 
| 
      
 237 
     | 
    
         
            +
                      parsed_element = yield(element)
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                      if parsed_element.nil? == false
         
     | 
| 
      
 240 
     | 
    
         
            +
                        elements.push(parsed_element)
         
     | 
| 
      
 241 
     | 
    
         
            +
                      end
         
     | 
| 
      
 242 
     | 
    
         
            +
                    end
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
                    if elements.length == 0
         
     | 
| 
      
 245 
     | 
    
         
            +
                      return nil
         
     | 
| 
      
 246 
     | 
    
         
            +
                    end
         
     | 
| 
      
 247 
     | 
    
         
            +
             
     | 
| 
      
 248 
     | 
    
         
            +
                    return elements
         
     | 
| 
      
 249 
     | 
    
         
            +
                  end
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
                  public
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
                  # Construct an instance from the given hash.
         
     | 
| 
      
 254 
     | 
    
         
            +
                  #
         
     | 
| 
      
 255 
     | 
    
         
            +
                  # If the given argument is nil or is not a Hash, nil is returned.
         
     | 
| 
      
 256 
     | 
    
         
            +
                  # Otherwise, Service.new(hash) is returned.
         
     | 
| 
      
 257 
     | 
    
         
            +
                  def self.parse(hash)
         
     | 
| 
      
 258 
     | 
    
         
            +
                    if hash.nil? or (hash.kind_of?(Hash) == false)
         
     | 
| 
      
 259 
     | 
    
         
            +
                      return nil
         
     | 
| 
      
 260 
     | 
    
         
            +
                    end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                    return Service.new(hash)
         
     | 
| 
      
 263 
     | 
    
         
            +
                  end
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
      
 265 
     | 
    
         
            +
                  # Set attribute values using the given hash.
         
     | 
| 
      
 266 
     | 
    
         
            +
                  def update(hash)
         
     | 
| 
      
 267 
     | 
    
         
            +
                    authlete_model_service_update(hash)
         
     | 
| 
      
 268 
     | 
    
         
            +
                  end
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
                  # Convert this object into a hash.
         
     | 
| 
      
 271 
     | 
    
         
            +
                  def to_hash
         
     | 
| 
      
 272 
     | 
    
         
            +
                    hash = {}
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
      
 274 
     | 
    
         
            +
                    instance_variables.each do |var|
         
     | 
| 
      
 275 
     | 
    
         
            +
                      key = var.to_s.delete("@").to_sym
         
     | 
| 
      
 276 
     | 
    
         
            +
                      val = instance_variable_get(var)
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
                      if authlete_model_service_simple_attribute?(key) or val.nil?
         
     | 
| 
      
 279 
     | 
    
         
            +
                        hash[key] = val
         
     | 
| 
      
 280 
     | 
    
         
            +
                      elsif val.kind_of?(Array)
         
     | 
| 
      
 281 
     | 
    
         
            +
                        hash[key] = val.map {|element| element.to_hash}
         
     | 
| 
      
 282 
     | 
    
         
            +
                      end
         
     | 
| 
      
 283 
     | 
    
         
            +
                    end
         
     | 
| 
      
 284 
     | 
    
         
            +
             
     | 
| 
      
 285 
     | 
    
         
            +
                    return hash
         
     | 
| 
      
 286 
     | 
    
         
            +
                  end
         
     | 
| 
       139 
287 
     | 
    
         
             
                end
         
     | 
| 
       140 
288 
     | 
    
         
             
              end
         
     | 
| 
       141 
289 
     | 
    
         
             
            end
         
     | 
| 
         @@ -15,6 +15,9 @@ 
     | 
|
| 
       15 
15 
     | 
    
         
             
            # limitations under the License.
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
            require 'set'
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       18 
21 
     | 
    
         
             
            module Authlete
         
     | 
| 
       19 
22 
     | 
    
         
             
              module Model
         
     | 
| 
       20 
23 
     | 
    
         
             
                class SnsCredentials
         
     | 
| 
         @@ -28,6 +31,77 @@ module Authlete 
     | 
|
| 
       28 
31 
     | 
    
         
             
                  #
         
     | 
| 
       29 
32 
     | 
    
         
             
                  # Valid values are "FACEBOOK".
         
     | 
| 
       30 
33 
     | 
    
         
             
                  attr_accessor :sns
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  private
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  # String attributes.
         
     | 
| 
      
 38 
     | 
    
         
            +
                  STRING_ATTRIBUTES = ::Set.new([:apiKey, :apiSecret, :sns])
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  # The constructor.
         
     | 
| 
      
 41 
     | 
    
         
            +
                  def initialize(hash = nil)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    # Set default values to string attributes.
         
     | 
| 
      
 43 
     | 
    
         
            +
                    STRING_ATTRIBUTES.each do |attr|
         
     | 
| 
      
 44 
     | 
    
         
            +
                      send("#{attr}=", nil)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    # Set attribute values using the given hash.
         
     | 
| 
      
 48 
     | 
    
         
            +
                    authlete_model_snsCredentials_update(hash)
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  def authlete_model_snsCredentials_simple_attribute?(key)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    STRING_ATTRIBUTES.include?(key)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  def authlete_model_snsCredentials_update(hash)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    if hash.nil?
         
     | 
| 
      
 57 
     | 
    
         
            +
                      return
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    hash.each do |key, value|
         
     | 
| 
      
 61 
     | 
    
         
            +
                      key = key.to_sym
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                      # If the attribute is a simple one.
         
     | 
| 
      
 64 
     | 
    
         
            +
                      if authlete_model_snsCredentials_simple_attribute?(key)
         
     | 
| 
      
 65 
     | 
    
         
            +
                        send("#{key}=", value)
         
     | 
| 
      
 66 
     | 
    
         
            +
                        next
         
     | 
| 
      
 67 
     | 
    
         
            +
                      end
         
     | 
| 
      
 68 
     | 
    
         
            +
                    end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    return self
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  public
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                  # Construct an instance from the given hash.
         
     | 
| 
      
 76 
     | 
    
         
            +
                  #
         
     | 
| 
      
 77 
     | 
    
         
            +
                  # If the given argument is nil or is not a Hash, nil is returned.
         
     | 
| 
      
 78 
     | 
    
         
            +
                  # Otherwise, SnsCredentials.new(hash) is returned.
         
     | 
| 
      
 79 
     | 
    
         
            +
                  def self.parse(hash)
         
     | 
| 
      
 80 
     | 
    
         
            +
                    if hash.nil? or (hash.kind_of?(Hash) == false)
         
     | 
| 
      
 81 
     | 
    
         
            +
                      return nil
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                    return Authlete::Model::SnsCredentials.new(hash)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                  # Set attribute values using the given hash.
         
     | 
| 
      
 88 
     | 
    
         
            +
                  def update(hash)
         
     | 
| 
      
 89 
     | 
    
         
            +
                    authlete_model_snsCredentials_update(hash)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                  # Convert this object into a hash.
         
     | 
| 
      
 93 
     | 
    
         
            +
                  def to_hash
         
     | 
| 
      
 94 
     | 
    
         
            +
                    hash = {}
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                    instance_variables.each do |var|
         
     | 
| 
      
 97 
     | 
    
         
            +
                      key = var.to_s.delete("@").to_sym
         
     | 
| 
      
 98 
     | 
    
         
            +
                      val = instance_variable_get(var)
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                      hash[key] = val
         
     | 
| 
      
 101 
     | 
    
         
            +
                    end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                    return hash
         
     | 
| 
      
 104 
     | 
    
         
            +
                  end
         
     | 
| 
       31 
105 
     | 
    
         
             
                end
         
     | 
| 
       32 
106 
     | 
    
         
             
              end
         
     | 
| 
       33 
107 
     | 
    
         
             
            end
         
     | 
    
        data/lib/authlete/version.rb
    CHANGED
    
    
    
        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.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Takahiko Kawasaki
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-05-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rest-client
         
     |