Class: JotForm::JotForm
- Inherits:
-
Object
- Object
- JotForm::JotForm
- Defined in:
- lib/jotform/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
-
#form(id) ⇒ Object
Methods that wrap the ‘getter’ methods in the vanilla library:.
- #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
14 15 16 17 18 |
# File 'lib/jotform/jotform.rb', line 14 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.
9 10 11 |
# File 'lib/jotform/jotform.rb', line 9 def apiKey @apiKey end |
#apiVersion ⇒ Object
Returns the value of attribute apiVersion.
11 12 13 |
# File 'lib/jotform/jotform.rb', line 11 def apiVersion @apiVersion end |
#baseURL ⇒ Object
Returns the value of attribute baseURL.
10 11 12 |
# File 'lib/jotform/jotform.rb', line 10 def baseURL @baseURL end |
Instance Method Details
#_executeGetRequest(endpoint, parameters = []) ⇒ Object
38 39 40 |
# File 'lib/jotform/jotform.rb', line 38 def _executeGetRequest(endpoint, parameters = []) return _executeHTTPRequest(endpoint,parameters, "GET") end |
#_executeHTTPRequest(endpoint, parameters = nil, type = "GET") ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jotform/jotform.rb', line 20 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
42 43 44 |
# File 'lib/jotform/jotform.rb', line 42 def _executePostRequest(endpoint, parameters = []) return _executeHTTPRequest(endpoint,parameters, "POST") end |
#createFormSubmissions(formID, submission) ⇒ Object
130 131 132 |
# File 'lib/jotform/jotform.rb', line 130 def createFormSubmissions(formID, submission) return _executePostRequest("form/"+ formID +"/submissions", submission); end |
#createFormWebhook(formID, webhookURL) ⇒ Object
126 127 128 |
# File 'lib/jotform/jotform.rb', line 126 def createFormWebhook(formID, webhookURL) return _executePostRequest("form/"+formID+"/webhooks",{"webhookURL" => webhookURL} ); end |
#form(id) ⇒ Object
Methods that wrap the ‘getter’ methods in the vanilla library:
135 136 137 138 |
# File 'lib/jotform/jotform.rb', line 135 def form(id) @form ||= {} @form[id] ||= ::JotForm::Form.new getForm(id) end |
#getFolder(folderID) ⇒ Object
122 123 124 |
# File 'lib/jotform/jotform.rb', line 122 def getFolder(folderID) return _executeGetRequest("folder/"+folderID) end |
#getFolders ⇒ Object
66 67 68 |
# File 'lib/jotform/jotform.rb', line 66 def getFolders return _executeGetRequest("user/folders") end |
#getForm(formID) ⇒ Object
82 83 84 |
# File 'lib/jotform/jotform.rb', line 82 def getForm(formID) return _executeGetRequest("form/"+ formID) end |
#getFormFiles(formID) ⇒ Object
106 107 108 |
# File 'lib/jotform/jotform.rb', line 106 def getFormFiles(formID) return _executeGetRequest("form/"+formID+"/files") end |
#getFormProperties(formID) ⇒ Object
94 95 96 |
# File 'lib/jotform/jotform.rb', line 94 def getFormProperties(formID) return _executeGetRequest("form/"+formID+"/properties") end |
#getFormProperty(formID, propertyKey) ⇒ Object
98 99 100 |
# File 'lib/jotform/jotform.rb', line 98 def getFormProperty(formID, propertyKey) return _executeGetRequest("form/"+formID+"/properties/"+propertyKey) end |
#getFormQuestion(formID, qid) ⇒ Object
90 91 92 |
# File 'lib/jotform/jotform.rb', line 90 def getFormQuestion(formID, qid) return _executeGetRequest("form/"+formID+"/question/"+qid) end |
#getFormQuestions(formID) ⇒ Object
86 87 88 |
# File 'lib/jotform/jotform.rb', line 86 def getFormQuestions(formID) return _executeGetRequest("form/"+formID+"/questions") end |
#getForms ⇒ Object
54 55 56 |
# File 'lib/jotform/jotform.rb', line 54 def getForms return _executeGetRequest("user/forms") end |
#getFormSubmissions(formID) ⇒ Object
102 103 104 |
# File 'lib/jotform/jotform.rb', line 102 def getFormSubmissions(formID) return _executeGetRequest("form/"+ formID +"/submissions") end |
#getFormWebhooks(formID) ⇒ Object
110 111 112 |
# File 'lib/jotform/jotform.rb', line 110 def getFormWebhooks(formID) return _executeGetRequest("form/"+formID+"/webhooks") end |
#getHistory ⇒ Object
78 79 80 |
# File 'lib/jotform/jotform.rb', line 78 def getHistory return _executeGetRequest("user/history") end |
#getReport(reportID) ⇒ Object
118 119 120 |
# File 'lib/jotform/jotform.rb', line 118 def getReport(reportID) return _executeGetRequest("report/"+reportID) end |
#getReports ⇒ Object
70 71 72 |
# File 'lib/jotform/jotform.rb', line 70 def getReports return _executeGetRequest("user/reports") end |
#getSettings ⇒ Object
74 75 76 |
# File 'lib/jotform/jotform.rb', line 74 def getSettings return _executeGetRequest("user/settings") end |
#getSubmission(sid) ⇒ Object
114 115 116 |
# File 'lib/jotform/jotform.rb', line 114 def getSubmission(sid) return _executeGetRequest("submission/"+sid) end |
#getSubmissions ⇒ Object
58 59 60 |
# File 'lib/jotform/jotform.rb', line 58 def getSubmissions return _executeGetRequest("user/submissions") end |
#getSubusers ⇒ Object
62 63 64 |
# File 'lib/jotform/jotform.rb', line 62 def getSubusers return _executeGetRequest("user/subusers") end |
#getUsage ⇒ Object
50 51 52 |
# File 'lib/jotform/jotform.rb', line 50 def getUsage return _executeGetRequest("user/usage"); end |
#getUser ⇒ Object
46 47 48 |
# File 'lib/jotform/jotform.rb', line 46 def getUser return _executeGetRequest("user") end |