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.



5
6
7
8
9
10
# File 'lib/nation_builder/client.rb', line 5

def initialize(args = {})
  args.each do |key, value|
    self.send("#{key}=".intern, value)
  end
  self.token = setup_client
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



3
4
5
# File 'lib/nation_builder/client.rb', line 3

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



3
4
5
# File 'lib/nation_builder/client.rb', line 3

def client_secret
  @client_secret
end

#hostnameObject

Returns the value of attribute hostname.



3
4
5
# File 'lib/nation_builder/client.rb', line 3

def hostname
  @hostname
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/nation_builder/client.rb', line 3

def password
  @password
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/nation_builder/client.rb', line 3

def token
  @token
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/nation_builder/client.rb', line 3

def username
  @username
end

Instance Method Details

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



16
17
18
# File 'lib/nation_builder/client.rb', line 16

def get(path, opts={})
  self.token.get "#{base_uri}#{path}", opts.merge(headers: headers)
end

#peopleObject



12
13
14
# File 'lib/nation_builder/client.rb', line 12

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

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



20
21
22
# File 'lib/nation_builder/client.rb', line 20

def post(path, opts={})
  self.token.post "#{base_uri}#{path}", opts.merge(headers: headers)
end

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



24
25
26
# File 'lib/nation_builder/client.rb', line 24

def put(path, opts={})
  self.token.put "#{base_uri}#{path}", opts.merge(headers: headers)
end