Skip to content

Instantly share code, notes, and snippets.

@patrickjholloway
Created December 9, 2013 19:35
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 patrickjholloway/7879397 to your computer and use it in GitHub Desktop.
Save patrickjholloway/7879397 to your computer and use it in GitHub Desktop.
git diff for my codez
commit fefdb75b6a6f99531fb8aaa29ee3a68572e26c8f
Author: Patrick Holloway <pholloway@patientslikeme.com>
Date: Mon Dec 9 14:32:22 2013 -0500
add ORE API calls to find and create survey invitations given a plm_user_id and a survey_session_id
diff --git a/lib/open_research_exchange.rb b/lib/open_research_exchange.rb
index 9e307ce..bddf3fa 100644
--- a/lib/open_research_exchange.rb
+++ b/lib/open_research_exchange.rb
@@ -47,8 +47,30 @@ class OpenResearchExchange
res['invitation']['token'] if res
end
+ def token_find(user_id, survey_session_id)
+ path = "tokens/find/#{user_id}/#{survey_session_id}"
+ result = get(path)
+ check_result(result,{result: result.body, user_id: user_id, survey_session_id: survey_session_id})
+ result = JSON.parse(result.body)['token']
+ end
+
+ def token_find_or_create(user_id, survey_session_id)
+ path = "tokens/find_or_create/#{user_id}/#{survey_session_id}"
+ result = post(path)
+ check_result(result,{result: result.body, user_id: user_id, survey_session_id: survey_session_id})
+ result = JSON.parse(result.body)['token']
+ end
+
private
+ def check_result(result, result_data)
+ Rollbar.report_message(
+ "Issue finding token or survey session from ORE",
+ "error",
+ result_data
+ ) unless result.message == "OK"
+ end
+
def get(path)
uri = URI("#{@root}/authed/#{path}")
sig = sign(uri.path)
(END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment