Last active
April 5, 2016 18:20
-
-
Save reganstarr/5f1423249c942856ae31d7925ab3050a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This code assumes that you have included a "freshbooksTimeEntryObject" somewhere in a previous Zap step. You can see the format of a "freshbooksTimeEntryObject" below. | |
freshbooksTimeEntryObject = { | |
"project_id": "25479", | |
"task_id": "302086", | |
"staff_id": "1", | |
"hours": "4", | |
"notes": "This is a note", | |
"date": "2016-01-31" | |
} | |
*/ | |
function extract_piece_of_data(entire_string_of_text, characters_before_desired_data, characters_after_desired_data) { | |
var desired_data_with_stuff_after_it = entire_string_of_text.substr(entire_string_of_text.indexOf(characters_before_desired_data) + characters_before_desired_data.length); | |
var desired_data = desired_data_with_stuff_after_it.substr(0, desired_data_with_stuff_after_it.indexOf(characters_after_desired_data)); | |
return desired_data; | |
} | |
var freshbooksTimeEntryObject = JSON.parse(extract_piece_of_data(input.commit_message, "freshbooksTimeEntryObject = ", "}") + "}"); | |
output = {project_id: freshbooksTimeEntryObject.project_id, task_id: freshbooksTimeEntryObject.task_id, staff_id: freshbooksTimeEntryObject.staff_id, hours: freshbooksTimeEntryObject.hours, notes: freshbooksTimeEntryObject.notes, date: freshbooksTimeEntryObject.date}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment