Class: ZohoCrm::Record::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- ZohoCrm::Record::CreateService
- Defined in:
- lib/zoho_crm/record/create_service.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
Instance Method Summary collapse
-
#call ⇒ Object
Create a record.
-
#initialize(module_name:, data:) ⇒ CreateService
constructor
A new instance of CreateService.
Constructor Details
#initialize(module_name:, data:) ⇒ CreateService
12 13 14 15 |
# File 'lib/zoho_crm/record/create_service.rb', line 12 def initialize(module_name:, data:) @module_name = module_name @data = data.is_a?(Array) ? data : [data] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/zoho_crm/record/create_service.rb', line 4 def data @data end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
4 5 6 |
# File 'lib/zoho_crm/record/create_service.rb', line 4 def module_name @module_name end |
Instance Method Details
#call ⇒ Object
Create a record.
www.zoho.com/crm/developer/docs/api/v7/insert-records.html
Examples
service = ZohoCrm::Record::CreateService.call(
module_name: 'Contacts',
data: {
'Email' => '[email protected]',
'First_Name' => 'Eric',
'Last_Name' => 'Cartman'
}
)
service.success? # => true
service.errors # => #<ActiveModel::Errors []>
service.response # => #<Faraday::Response ...>
service.response.status # => 201
service.response.body # => {}
service.facade # => #<ZohoCrm::Record::Facade ...>
service.facade.attributes
service.attributes
POST /crm/v7/:module_name
44 45 46 |
# File 'lib/zoho_crm/record/create_service.rb', line 44 def call connection.post(module_name, **params) end |