Make body argument for query_api more clear
This commit is contained in:
parent
563d283e5b
commit
a6e76e3c90
1 changed files with 15 additions and 15 deletions
|
|
@ -8,33 +8,33 @@ class MailblusterManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.query_api(method, path, body)
|
def self.query_api(method, path, body: {})
|
||||||
options = @auth_headers.merge(body: body.to_json)
|
options = @auth_headers.merge(body: body.to_json)
|
||||||
send(method, path, options).parsed_response
|
send(method, path, options).parsed_response
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_lead(user)
|
def self.create_lead(user)
|
||||||
query_api(:post, '/',
|
query_api(:post, '/', body: {
|
||||||
'email' => user.email,
|
'email' => user.email,
|
||||||
'firstName' => user.name,
|
'firstName' => user.name,
|
||||||
'overrideExisting' => true,
|
'overrideExisting' => true,
|
||||||
'subscribed' => true,
|
'subscribed' => true,
|
||||||
'tags' => [ENV['OSEM_NAME'] || 'snapcon']
|
'tags' => [ENV['OSEM_NAME'] || 'snapcon']
|
||||||
)
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.edit_lead(user, add_tags: [], remove_tags: [], old_email: nil)
|
def self.edit_lead(user, add_tags: [], remove_tags: [], old_email: nil)
|
||||||
email_hash = Digest::MD5.hexdigest(old_email.presence || user.email)
|
email_hash = Digest::MD5.hexdigest(old_email.presence || user.email)
|
||||||
query_api(:put, "/#{email_hash}",
|
query_api(:put, "/#{email_hash}", body: {
|
||||||
'email' => user.email,
|
'email' => user.email,
|
||||||
'firstName' => user.name,
|
'firstName' => user.name,
|
||||||
'addTags' => add_tags,
|
'addTags' => add_tags,
|
||||||
'removeTags' => remove_tags
|
'removeTags' => remove_tags
|
||||||
)
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.delete_lead(user)
|
def self.delete_lead(user)
|
||||||
email_hash = Digest::MD5.hexdigest user.email
|
email_hash = Digest::MD5.hexdigest user.email
|
||||||
query_api(:delete, "/#{email_hash}", {})
|
query_api(:delete, "/#{email_hash}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue