Class: TheCity::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/the_city/client.rb

Direct Known Subclasses

API::Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ TheCity::API::Client

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
# File 'lib/the_city/client.rb', line 13

def initialize(options={})
  for key, value in options
    send(:"#{key}=", value)
  end
  yield self if block_given?
end

Instance Attribute Details

#access_tokenString Also known as: oauth_token

Returns:

  • (String)


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_idString

Returns:

  • (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_secretString

Returns:

  • (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

#subdomainString

Returns:

  • (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

#versionString Also known as: api_version

Returns:

  • (String)


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

#credentialsHash

Returns:

  • (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

Returns:

  • (Boolean)


79
80
81
# File 'lib/the_city/client.rb', line 79

def credentials?
  credentials.values.all?
end