Class: NationBuilder::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
21
22
23
24
25
# File 'lib/nation_builder/client.rb', line 16

def initialize(args = {})
  args.each do |key, value|
    self.send("#{key}=".intern, value)
  end
  if username.present? && password.present?
    self.client = setup_client_from_password
  elsif token.present?
    self.client = setup_client_from_token
  end
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def client
  @client
end

#client_idObject

Returns the value of attribute client_id.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def client_secret
  @client_secret
end

#hostnameObject

Returns the value of attribute hostname.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def hostname
  @hostname
end

#instrumentationObject

Returns the value of attribute instrumentation.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def instrumentation
  @instrumentation
end

#loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def password
  @password
end

#tokenObject

Returns the value of attribute token.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def token
  @token
end

#usernameObject

Returns the value of attribute username.



14
15
16
# File 'lib/nation_builder/client.rb', line 14

def username
  @username
end

Instance Method Details

#delete(path, opts = {}) ⇒ Object



47
48
49
# File 'lib/nation_builder/client.rb', line 47

def delete(path, opts={})
  instrumented_request(:delete, path, opts)
end

#get(path, opts = {}) ⇒ Object



35
36
37
# File 'lib/nation_builder/client.rb', line 35

def get(path, opts={})
  instrumented_request(:get, path, opts)
end

#peopleObject



27
28
29
# File 'lib/nation_builder/client.rb', line 27

def people
  NationBuilder::People.new(self)
end

#post(path, opts = {}) ⇒ Object



39
40
41
# File 'lib/nation_builder/client.rb', line 39

def post(path, opts={})
  instrumented_request(:post, path, opts)
end

#put(path, opts = {}) ⇒ Object



43
44
45
# File 'lib/nation_builder/client.rb', line 43

def put(path, opts={})
  instrumented_request(:put, path, opts)
end

#tagsObject



31
32
33
# File 'lib/nation_builder/client.rb', line 31

def tags
  NationBuilder::Tags.new(self)
end