Module: ChartMogul::API::Actions::Create
- Included in:
- Contact, Customer, CustomerInvoices, DataSource, Metrics::ActivitiesExport, Note, Opportunity, Plan, PlanGroup, Transactions::Payment, Transactions::Refund
- Defined in:
- lib/chartmogul/api/actions/create.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/chartmogul/api/actions/create.rb', line 7 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#create! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/chartmogul/api/actions/create.rb', line 11 def create! resp = handling_errors do connection.post(resource_path.apply(instance_attributes)) do |req| req.headers['Content-Type'] = 'application/json' req.body = JSON.dump(serialize_for_write) end end json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: self.class.immutable_keys) assign_all_attributes(json) end |