Skip to content

Instantly share code, notes, and snippets.

@mmcguff
Created August 24, 2020 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmcguff/c669cf82391938f78e8ff839ed3908f2 to your computer and use it in GitHub Desktop.
Save mmcguff/c669cf82391938f78e8ff839ed3908f2 to your computer and use it in GitHub Desktop.
{
new_or_modified_opportunitites: {
#type: :paging_desc,
input_fields: -> () {
[
{
name: "date_modified",
type: :timestamp,
optional: false
}
]
},
poll: -> (connection, input, next_page) {
max_num = 1;
params = {
max_num: max_num,
offset: next_page
}.reject {|k, v| v.present? == false}
date_modified_since = (input["date_modified"]).to_time.utc.iso8601
response = post(connection["base_url"] + "/Opportunities/filter",
{
"filter":[
{
"date_modified":{
"$gte": "#{date_modified_since}"
}
}
]
}
).params(params)
opportuntities = response["records"][0];
if response["next_offset"] < 1
next_offset = -1
else
next_offset = response["next_offset"]
end
if next_offset > 0
can_poll_more = true
else
can_poll_more = false
end
{
events: opportuntities,
next_page: next_offset,
can_poll_more: can_poll_more
}
},
output_fields: -> (object_definitions){
object_definitions["opporutnity"]
},
dedup: ->(event){
event["id"]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment