Class: Custplace::Base
- Inherits:
-
Object
- Object
- Custplace::Base
- Includes:
- HTTParty
- Defined in:
- lib/custplace/base.rb
Constant Summary collapse
- API_VERSION =
'3.1.0'
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #default_headers ⇒ Object
- #get(path, params: {}) ⇒ Object
-
#initialize(client) ⇒ Custplace::Api::Base
constructor
Initialize a new Custplace::Api::Base.
- #post(path, params: {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Custplace::Api::Base
Initialize a new Custplace::Api::Base
16 17 18 |
# File 'lib/custplace/base.rb', line 16 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/custplace/base.rb', line 10 def client @client end |
Instance Method Details
#default_headers ⇒ Object
20 21 22 23 24 25 |
# File 'lib/custplace/base.rb', line 20 def default_headers { "Custplace-Version": API_VERSION, "Authorization": "Bearer #{client.access_token}" } end |
#get(path, params: {}) ⇒ Object
27 28 29 30 31 |
# File 'lib/custplace/base.rb', line 27 def get(path, params: {}) response = self.class.get("#{account_base_url}#{path}", query: params, headers: default_headers) parsed_response = response.parsed_response parsed_response end |
#post(path, params: {}) ⇒ Object
33 34 35 36 37 |
# File 'lib/custplace/base.rb', line 33 def post(path, params: {}) response = self.class.post("#{account_base_url}#{path}", body: params.to_json, headers: default_headers) parsed_response = response.parsed_response parsed_response end |