Sha256: 493dc164b63b6775acc2e4e6d6330c8e4838b8042e911166f4d967d731afa6d3
Contents?: true
Size: 1.2 KB
Versions: 4
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module ChartMogul module API module Actions module Custom def self.included(base) base.extend ClassMethods end def custom_without_assign!(http_method, http_path, body_data = {}) self.class.custom_without_assign!(http_method, http_path, body_data) end def custom!(http_method, http_path, body_data = {}) json = custom_without_assign!(http_method, http_path, body_data) assign_all_attributes(json) end module ClassMethods 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 ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion) end def custom!(http_method, http_path, body_data = {}) json = custom_without_assign!(http_method, http_path, body_data) new_from_json(json) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems