Class: Jotform
- Inherits:
-
Object
- Object
- Jotform
- Defined in:
- lib/jotform.rb
Instance Attribute Summary collapse
-
#apiKey ⇒ Object
Returns the value of attribute apiKey.
-
#apiVersion ⇒ Object
Returns the value of attribute apiVersion.
-
#baseURL ⇒ Object
Returns the value of attribute baseURL.
Instance Method Summary collapse
- #_executeGetRequest(endpoint, parameters = []) ⇒ Object
- #_executeHTTPRequest(endpoint, parameters = nil, type = "GET") ⇒ Object
- #_executePostRequest(endpoint, parameters = []) ⇒ Object
- #createFormSubmissions(formID, submission) ⇒ Object
- #createFormWebhook(formID, webhookURL) ⇒ Object
- #getFolder(folderID) ⇒ Object
- #getFolders ⇒ Object
- #getForm(formID) ⇒ Object
- #getFormFiles(formID) ⇒ Object
- #getFormProperties(formID) ⇒ Object
- #getFormProperty(formID, propertyKey) ⇒ Object
- #getFormQuestion(formID, qid) ⇒ Object
- #getFormQuestions(formID) ⇒ Object
- #getForms ⇒ Object
- #getFormSubmissions(formID) ⇒ Object
- #getFormWebhooks(formID) ⇒ Object
- #getHistory ⇒ Object
- #getReport(reportID) ⇒ Object
- #getReports ⇒ Object
- #getSettings ⇒ Object
- #getSubmission(sid) ⇒ Object
- #getSubmissions ⇒ Object
- #getSubusers ⇒ Object
- #getUsage ⇒ Object
- #getUser ⇒ Object
-
#initialize(apiKey = nil, baseURL = "http://api.jotform.com", apiVersion = "v1") ⇒ Jotform
constructor
Create the object.
Constructor Details
#initialize(apiKey = nil, baseURL = "http://api.jotform.com", apiVersion = "v1") ⇒ Jotform
Create the object
7 8 9 10 11 |
# File 'lib/jotform.rb', line 7 def initialize(apiKey = nil, baseURL = "http://api.jotform.com", apiVersion = "v1") @apiKey = apiKey @baseURL = baseURL @apiVersion = apiVersion end |
Instance Attribute Details
#apiKey ⇒ Object
Returns the value of attribute apiKey.
2 3 4 |
# File 'lib/jotform.rb', line 2 def apiKey @apiKey end |
#apiVersion ⇒ Object
Returns the value of attribute apiVersion.
4 5 6 |
# File 'lib/jotform.rb', line 4 def apiVersion @apiVersion end |
#baseURL ⇒ Object
Returns the value of attribute baseURL.
3 4 5 |
# File 'lib/jotform.rb', line 3 def baseURL @baseURL end |
Instance Method Details
#_executeGetRequest(endpoint, parameters = []) ⇒ Object
31 32 33 |
# File 'lib/jotform.rb', line 31 def _executeGetRequest(endpoint, parameters = []) return _executeHTTPRequest(endpoint,parameters, "GET") end |
#_executeHTTPRequest(endpoint, parameters = nil, type = "GET") ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jotform.rb', line 13 def _executeHTTPRequest(endpoint, parameters = nil, type = "GET") url = [@baseURL, @apiVersion, endpoint].join("/").concat('?apiKey='+@apiKey) url = URI.parse(url) if type == "GET" response = Net::HTTP.get_response(url) elsif type == "POST" response = Net::HTTP.post_form(url, parameters) end if response.kind_of? Net::HTTPSuccess return JSON.parse(response.body)["content"] else puts JSON.parse(response.body)["message"] return nil end end |
#_executePostRequest(endpoint, parameters = []) ⇒ Object
35 36 37 |
# File 'lib/jotform.rb', line 35 def _executePostRequest(endpoint, parameters = []) return _executeHTTPRequest(endpoint,parameters, "POST") end |
#createFormSubmissions(formID, submission) ⇒ Object
124 125 126 |
# File 'lib/jotform.rb', line 124 def createFormSubmissions(formID, submission) return _executePostRequest("form/"+ formID +"/submissions", submission); end |
#createFormWebhook(formID, webhookURL) ⇒ Object
120 121 122 |
# File 'lib/jotform.rb', line 120 def createFormWebhook(formID, webhookURL) return _executePostRequest("form/"+formID+"/webhooks",{"webhookURL" => webhookURL} ); end |
#getFolder(folderID) ⇒ Object
116 117 118 |
# File 'lib/jotform.rb', line 116 def getFolder(folderID) return _executeGetRequest("folder/"+folderID) end |
#getFolders ⇒ Object
59 60 61 |
# File 'lib/jotform.rb', line 59 def getFolders return _executeGetRequest("user/folders") end |
#getForm(formID) ⇒ Object
75 76 77 |
# File 'lib/jotform.rb', line 75 def getForm(formID) return _executeGetRequest("form/"+ formID) end |
#getFormFiles(formID) ⇒ Object
100 101 102 |
# File 'lib/jotform.rb', line 100 def getFormFiles(formID) return _executeGetRequest("form/"+formID+"/files") end |
#getFormProperties(formID) ⇒ Object
87 88 89 |
# File 'lib/jotform.rb', line 87 def getFormProperties(formID) return _executeGetRequest("form/"+formID+"/properties") end |
#getFormProperty(formID, propertyKey) ⇒ Object
91 92 93 |
# File 'lib/jotform.rb', line 91 def getFormProperty(formID, propertyKey) return _executeGetRequest("form/"+formID+"/properties/"+propertyKey) end |
#getFormQuestion(formID, qid) ⇒ Object
83 84 85 |
# File 'lib/jotform.rb', line 83 def getFormQuestion(formID, qid) return _executeGetRequest("form/"+formID+"/question/"+qid) end |
#getFormQuestions(formID) ⇒ Object
79 80 81 |
# File 'lib/jotform.rb', line 79 def getFormQuestions(formID) return _executeGetRequest("form/"+formID+"/questions") end |
#getForms ⇒ Object
47 48 49 |
# File 'lib/jotform.rb', line 47 def getForms return _executeGetRequest("user/forms") end |
#getFormSubmissions(formID) ⇒ Object
96 97 98 |
# File 'lib/jotform.rb', line 96 def getFormSubmissions(formID) return _executeGetRequest("form/"+ formID +"/submissions") end |
#getFormWebhooks(formID) ⇒ Object
104 105 106 |
# File 'lib/jotform.rb', line 104 def getFormWebhooks(formID) return _executeGetRequest("form/"+formID+"/webhooks") end |
#getHistory ⇒ Object
71 72 73 |
# File 'lib/jotform.rb', line 71 def getHistory return _executeGetRequest("user/history") end |
#getReport(reportID) ⇒ Object
112 113 114 |
# File 'lib/jotform.rb', line 112 def getReport(reportID) return _executeGetRequest("report/"+reportID) end |
#getReports ⇒ Object
63 64 65 |
# File 'lib/jotform.rb', line 63 def getReports return _executeGetRequest("user/reports") end |
#getSettings ⇒ Object
67 68 69 |
# File 'lib/jotform.rb', line 67 def getSettings return _executeGetRequest("user/settings") end |
#getSubmission(sid) ⇒ Object
108 109 110 |
# File 'lib/jotform.rb', line 108 def getSubmission(sid) return _executeGetRequest("submission/"+sid) end |
#getSubmissions ⇒ Object
51 52 53 |
# File 'lib/jotform.rb', line 51 def getSubmissions return _executeGetRequest("user/submissions") end |
#getSubusers ⇒ Object
55 56 57 |
# File 'lib/jotform.rb', line 55 def getSubusers return _executeGetRequest("user/subusers") end |
#getUsage ⇒ Object
43 44 45 |
# File 'lib/jotform.rb', line 43 def getUsage return _executeGetRequest("user/usage"); end |
#getUser ⇒ Object
39 40 41 |
# File 'lib/jotform.rb', line 39 def getUser return _executeGetRequest("user") end |