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) ⇒ Object
-
#initialize(args = {}) ⇒ Client
constructor
A new instance of Client.
- #people ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Client
5 6 7 8 9 10 11 |
# File 'lib/nation_builder/client.rb', line 5 def initialize(args = {}) args.each do |key, value| self.send("#{key}=".intern, value) end client = OAuth2::Client.new(client_id, client_secret, :site => "https://#{hostname}", authorize_url: "https://#{hostname}/oauth/authorize", token_url: "https://#{hostname}/oauth/token" ) self.token = client.password.get_token(username, password) 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) ⇒ Object
18 19 20 |
# File 'lib/nation_builder/client.rb', line 18 def get(path) self.token.get "https://#{hostname}/#{path}" end |
#people ⇒ Object
14 15 16 |
# File 'lib/nation_builder/client.rb', line 14 def people NationBuilder::People.new(self) end |