Module: ChartMogul::API::Actions::Custom::ClassMethods
- Defined in:
- lib/chartmogul/api/actions/custom.rb
Instance Method Summary collapse
- #custom!(http_method, http_path, body_data = {}) ⇒ Object
- #custom_without_assign!(http_method, http_path, body_data = {}) ⇒ Object
Instance Method Details
#custom!(http_method, http_path, body_data = {}) ⇒ Object
32 33 34 35 |
# File 'lib/chartmogul/api/actions/custom.rb', line 32 def custom!(http_method, http_path, body_data = {}) json = custom_without_assign!(http_method, http_path, body_data) new_from_json(json) end |
#custom_without_assign!(http_method, http_path, body_data = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chartmogul/api/actions/custom.rb', line 21 def custom_without_assign!(http_method, http_path, body_data = {}) resp = handling_errors do connection.send(http_method, http_path) do |req| req.headers['Content-Type'] = 'application/json' req.body = JSON.dump(body_data) end end parsed_body = resp.body.empty? ? '{}' : resp.body ChartMogul::Utils::JSONParser.parse(parsed_body, immutable_keys: immutable_keys) end |