Class: TheCity::Client
- Inherits:
-
Object
- Object
- TheCity::Client
- Defined in:
- lib/the_city/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #access_token ⇒ String (also: #oauth_token)
- #app_id ⇒ String
- #app_secret ⇒ String
- #subdomain ⇒ String
- #version ⇒ String (also: #api_version)
Instance Method Summary collapse
- #credentials ⇒ Hash
- #credentials? ⇒ Boolean
-
#initialize(options = {}) {|_self| ... } ⇒ TheCity::API::Client
constructor
Initializes a new Client object.
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ TheCity::API::Client
Initializes a new Client object
13 14 15 16 17 18 |
# File 'lib/the_city/client.rb', line 13 def initialize(={}) for key, value in send(:"#{key}=", value) end yield self if block_given? end |
Instance Attribute Details
#access_token ⇒ String Also known as: oauth_token
48 49 50 51 52 53 54 |
# File 'lib/the_city/client.rb', line 48 def access_token if instance_variable_defined?(:@access_token) @access_token else ENV['THECITY_ACCESS_TOKEN'] end end |
#app_id ⇒ String
30 31 32 33 34 35 36 |
# File 'lib/the_city/client.rb', line 30 def app_id if instance_variable_defined?(:@app_id) @app_id else ENV['THECITY_APP_ID'] end end |
#app_secret ⇒ String
39 40 41 42 43 44 45 |
# File 'lib/the_city/client.rb', line 39 def app_secret if instance_variable_defined?(:@app_secret) @app_secret else ENV['THECITY_APP_SECRET'] end end |
#subdomain ⇒ String
21 22 23 24 25 26 27 |
# File 'lib/the_city/client.rb', line 21 def subdomain if instance_variable_defined?(:@subdomain) @subdomain else ENV['THECITY_SUBDOMAIN'] end end |
#version ⇒ String Also known as: api_version
58 59 60 61 62 63 64 65 66 |
# File 'lib/the_city/client.rb', line 58 def version if instance_variable_defined?(:@version) @api_version || "1" elsif ENV['THECITY_API_VERSION'] ENV['THECITY_API_VERSION'] else "1" end end |
Instance Method Details
#credentials ⇒ Hash
70 71 72 73 74 75 76 |
# File 'lib/the_city/client.rb', line 70 def credentials { :app_id => app_id, :app_secret => app_secret, :token => access_token, } end |
#credentials? ⇒ Boolean
79 80 81 |
# File 'lib/the_city/client.rb', line 79 def credentials? credentials.values.all? end |