Create Pipedrive::API put helpers
This commit is contained in:
parent
1f226d882c
commit
e31b839e0c
3 changed files with 21 additions and 13 deletions
|
@ -1,9 +1,23 @@
|
||||||
class Pipedrive::API
|
class Pipedrive::API
|
||||||
def self.put(url, params)
|
|
||||||
RestClient.put(url, params, { content_type: :json })
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get(url, params)
|
def self.get(url, params)
|
||||||
RestClient.get(url, params: params)
|
RestClient.get(url, params: params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.put_deal(deal_id, params)
|
||||||
|
url = PIPEDRIVE_DEALS_URL + "/#{deal_id}?api_token=#{PIPEDRIVE_TOKEN}"
|
||||||
|
|
||||||
|
self.put(url, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.put_person(person_id, params)
|
||||||
|
url = PIPEDRIVE_PEOPLE_URL + "/#{person_id}?api_token=#{PIPEDRIVE_TOKEN}"
|
||||||
|
|
||||||
|
self.put(url, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def self.put(url, params)
|
||||||
|
RestClient.put(url, params, { content_type: :json })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,8 +15,6 @@ class Pipedrive::DealAdapter
|
||||||
PIPEDRIVE_CAMILLE_ID = '3189424'
|
PIPEDRIVE_CAMILLE_ID = '3189424'
|
||||||
|
|
||||||
def self.refuse_deal(deal_id, owner_id)
|
def self.refuse_deal(deal_id, owner_id)
|
||||||
url = PIPEDRIVE_DEALS_URL + "/#{deal_id}?api_token=#{PIPEDRIVE_TOKEN}"
|
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
user_id: owner_id,
|
user_id: owner_id,
|
||||||
stage_id: PIPEDRIVE_ORGANISMES_REFUSES_STOCK_STAGE_ID,
|
stage_id: PIPEDRIVE_ORGANISMES_REFUSES_STOCK_STAGE_ID,
|
||||||
|
@ -24,7 +22,7 @@ class Pipedrive::DealAdapter
|
||||||
lost_reason: PIPEDRIVE_LOST_REASON
|
lost_reason: PIPEDRIVE_LOST_REASON
|
||||||
}
|
}
|
||||||
|
|
||||||
Pipedrive::API.put(url, params.to_json)
|
Pipedrive::API.put_deal(deal_id, params.to_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.fetch_waiting_deal_ids(person_id)
|
def self.fetch_waiting_deal_ids(person_id)
|
||||||
|
@ -44,10 +42,8 @@ class Pipedrive::DealAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_deal_owner_and_stage(deal_id, owner_id, stage_id)
|
def self.update_deal_owner_and_stage(deal_id, owner_id, stage_id)
|
||||||
url = PIPEDRIVE_DEALS_URL + "/#{deal_id}?api_token=#{PIPEDRIVE_TOKEN}"
|
|
||||||
|
|
||||||
params = { user_id: owner_id, stage_id: stage_id }
|
params = { user_id: owner_id, stage_id: stage_id }
|
||||||
|
|
||||||
Pipedrive::API.put(url, params.to_json)
|
Pipedrive::API.put_deal(deal_id, params.to_json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,10 +25,8 @@ class Pipedrive::PersonAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update_person_owner(person_id, owner_id)
|
def self.update_person_owner(person_id, owner_id)
|
||||||
url = PIPEDRIVE_PEOPLE_URL + "/#{person_id}?api_token=#{PIPEDRIVE_TOKEN}"
|
|
||||||
|
|
||||||
params = { owner_id: owner_id }
|
params = { owner_id: owner_id }
|
||||||
|
|
||||||
Pipedrive::API.put(url, params.to_json)
|
Pipedrive::API.put_person(person_id, params.to_json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue