Class: ZohoCrm::Record::UpsertService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/zoho_crm/record/upsert_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(module_name:, data:, duplicate_check_fields: [], skip_feature_execution: [], trigger: []) ⇒ UpsertService

Returns a new instance of UpsertService.



12
13
14
15
16
17
18
# File 'lib/zoho_crm/record/upsert_service.rb', line 12

def initialize(module_name:, data:, duplicate_check_fields: [], skip_feature_execution: [], trigger: [])
  @module_name            = module_name
  @data                   = data.is_a?(Array) ? data : [data]
  @duplicate_check_fields = duplicate_check_fields
  @skip_feature_execution = skip_feature_execution
  @trigger                = trigger
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/zoho_crm/record/upsert_service.rb', line 4

def data
  @data
end

#duplicate_check_fieldsObject (readonly)

Returns the value of attribute duplicate_check_fields.



4
5
6
# File 'lib/zoho_crm/record/upsert_service.rb', line 4

def duplicate_check_fields
  @duplicate_check_fields
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



4
5
6
# File 'lib/zoho_crm/record/upsert_service.rb', line 4

def module_name
  @module_name
end

#skip_feature_executionObject (readonly)

Returns the value of attribute skip_feature_execution.



4
5
6
# File 'lib/zoho_crm/record/upsert_service.rb', line 4

def skip_feature_execution
  @skip_feature_execution
end

#triggerObject (readonly)

Returns the value of attribute trigger.



4
5
6
# File 'lib/zoho_crm/record/upsert_service.rb', line 4

def trigger
  @trigger
end

Instance Method Details

#callObject

Create a record.

www.zoho.com/crm/developer/docs/api/v7/upsert-records.html

Examples

service = ZohoCrm::Record::UpsertService.call(
  module_name: 'Contacts',
  data: {
    'Email' => '[email protected]',
    'First_Name' => 'Eric',
    'Last_Name' => 'Cartman Theodore 2nd'
  },
  duplicate_check_fields: ['Email']
)

service.success? # => true
service.errors # => #<ActiveModel::Errors []>

service.response # => #<Faraday::Response ...>
service.response.status # => 200
service.response.body # => {}

service.facade # => #<ZohoCrm::Record::Facade ...>
service.facade.attributes
service.attributes

POST /crm/v7/:module_name/upsert



48
49
50
# File 'lib/zoho_crm/record/upsert_service.rb', line 48

def call
  connection.post("#{module_name}/upsert", **params)
end