lib/mrkt/concerns/crud_leads.rb in mrkt-1.0.0 vs lib/mrkt/concerns/crud_leads.rb in mrkt-1.0.1
- old
+ new
@@ -1,19 +1,19 @@
module Mrkt
module CrudLeads
def get_lead_by_id(id, fields: nil)
optional = {
- fields: fields&.join(',')
+ fields: fields
}
get("/rest/v1/lead/#{id}.json", {}, optional)
end
def get_leads(filter_type, filter_values, fields: nil, batch_size: nil, next_page_token: nil)
params = {
filterType: filter_type,
- filterValues: filter_values.join(',')
+ filterValues: filter_values
}
optional = {
fields: fields,
batchSize: batch_size,
@@ -45,21 +45,23 @@
json_payload(req, input: map_lead_ids(leads))
end
end
def associate_lead(id, cookie)
- params = Faraday::Utils::ParamsHash.new
- params[:cookie] = cookie
+ params = Mrkt::Faraday::ParamsEncoder.encode(cookie: cookie)
- post_json("/rest/v1/leads/#{id}/associate.json?#{params.to_query}")
+ post_json("/rest/v1/leads/#{id}/associate.json?#{params}")
end
def merge_leads(winning_lead_id, losing_lead_ids, merge_in_crm: false)
- params = Faraday::Utils::ParamsHash.new
+ params = {}
+
params[:mergeInCRM] = merge_in_crm
- params[:leadIds] = losing_lead_ids.join(',') if losing_lead_ids
+ params[:leadIds] = losing_lead_ids if losing_lead_ids
- post_json("/rest/v1/leads/#{winning_lead_id}/merge.json?#{params.to_query}")
+ query_params = Mrkt::Faraday::ParamsEncoder.encode(params)
+
+ post_json("/rest/v1/leads/#{winning_lead_id}/merge.json?#{query_params}")
end
def describe_lead
get('/rest/v1/leads/describe.json')
end