Class: Pipedrive::Base
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Pipedrive::Base
- Includes:
- HTTParty
- Defined in:
- lib/pipedrive/base.rb
Overview
Base class for setting HTTParty configurations globally
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
-
.authenticate(token) ⇒ Hash
Sets the authentication credentials in a class variable.
-
.bad_response(response) ⇒ Object
Examines a bad response and raises an approriate exception.
- .new_list(attrs) ⇒ Object
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ CloudApp::Base
constructor
Create a new CloudApp::Base object.
Constructor Details
#initialize(attrs = {}) ⇒ CloudApp::Base
Create a new CloudApp::Base object.
Only used internally
52 53 54 |
# File 'lib/pipedrive/base.rb', line 52 def initialize(attrs = {}) super( attrs['data'] ) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
44 45 46 |
# File 'lib/pipedrive/base.rb', line 44 def data @data end |
Class Method Details
.authenticate(token) ⇒ Hash
Sets the authentication credentials in a class variable.
26 27 28 |
# File 'lib/pipedrive/base.rb', line 26 def self.authenticate(token) self.default_params :api_token => token end |
.bad_response(response) ⇒ Object
Examines a bad response and raises an approriate exception
33 34 35 36 37 38 |
# File 'lib/pipedrive/base.rb', line 33 def self.bad_response(response) if response.class == HTTParty::Response raise ResponseError, response end raise StandardError, "Unkown error" end |
.new_list(attrs) ⇒ Object
40 41 42 |
# File 'lib/pipedrive/base.rb', line 40 def self.new_list( attrs ) attrs['data'].is_a?(Array) ? attrs['data'].map {|data| self.new( 'data' => data ) } : [] end |