Class: NationBuilder::Client
- Inherits:
-
Object
- Object
- NationBuilder::Client
- Defined in:
- lib/nation_builder/client.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#password ⇒ Object
Returns the value of attribute password.
-
#token ⇒ Object
Returns the value of attribute token.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #get(path, opts = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Client
constructor
A new instance of Client.
- #people ⇒ Object
- #post(path, opts = {}) ⇒ Object
- #put(path, opts = {}) ⇒ Object
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_id ⇒ Object
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_secret ⇒ Object
Returns the value of attribute client_secret.
3 4 5 |
# File 'lib/nation_builder/client.rb', line 3 def client_secret @client_secret end |
#hostname ⇒ Object
Returns the value of attribute hostname.
3 4 5 |
# File 'lib/nation_builder/client.rb', line 3 def hostname @hostname end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/nation_builder/client.rb', line 3 def password @password end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/nation_builder/client.rb', line 3 def token @token end |
#username ⇒ Object
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 |
#people ⇒ Object
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 |