GithubHelp home page GithubHelp logo

jotform-api-scala's Introduction

jotform-api-scala

JotForm API - Scala Client

Installation

Install via git clone:

    $ git clone git://github.com/jotform/jotform-api-scala.git
    $ cd jotform-api-scala

Documentation

You can find the docs for the API of this client at https://api.jotform.com/docs/

Authentication

JotForm API requires API key for all user related calls. You can create your API Keys at API section of My Account page.

Examples

Print all forms of the user

package com.jotform.api.samples

import com.jotform.api._
import org.json._

object PrintFormList {
  
  def main(args: Array[String]) {
    val client = new JotForm()
    client.setAPIKey("YOUR API KEY")
    
    val response: JSONObject = client.getForms()
    
    val forms: JSONArray = response.getJSONArray("content")
			
	for (i <- 0 until forms.length()){
		val form: JSONObject = forms.getJSONObject(i)
		
		println(form.get("title") + " (Total:" +form.get("count") + " New:" + form.get("new") + ")")
	}
  }
}

Get submissions of the latest form

package com.jotform.api.samples

import com.jotform.api._
import org.json._

object LatestFormSubmissions {
  
  def main(args: Array[String]) {
    val client = new JotForm()
    client.setAPIKey("YOUR API KEY")
    
    val response: JSONObject = client.getForms(0, 1, null, null)
    
    val forms: JSONArray = response.getJSONArray("content")
    
    val latestForm: JSONObject = forms.getJSONObject(0)
    
    val latestFormID: Long = latestForm.getLong("id")
    
    val submissions: JSONObject = client.getFormSubmissions(latestFormID)
    
    println(submissions)

  }
}

Get latest 100 submissions ordered by creation date

package com.jotform.api.samples

import com.jotform.api._
import org.json._

object Latest100Submissions {
  
  def main(args: Array[String]) {
    val client = new JotForm()
    client.setAPIKey("YOUR API KEY")
    
    val response: JSONObject = client.getSubmissions(0, 100, null, "created_at")

    println(response)

  }
}

Submission and form filter examples

package com.jotform.api.samples

import com.jotform.api._
import org.json._

object SubmissionFormFilters {
  
  def main(args: Array[String]) {
    val client = new JotForm()
    client.setAPIKey("YOUR API KEY")
    
    val submissionfilter = Map("id:gt" -> "244605793257787946", "created_at:gt" -> "2013-09-06 03:18:44")
    
    val submissions: JSONObject = client.getSubmissions(0, 0, submissionfilter, null)

    println(submissions)
    
    val formFilter = Map("id:gt" -> "32522773744962")
    
    val forms: JSONObject = client.getForms(0, 0, formFilter, null)
    
    println(forms)
  }
}

Delete last 50 submissions

package com.jotform.api.samples

import com.jotform.api._
import org.json._

object Delete50Submissions{
  
  def main(args: Array[String]) {
    val client = new JotForm()
    client.setAPIKey("YOUR API KEY")
    
    val response: JSONObject = client.getSubmissions(0, 2, null, null)
    
    val submissions = response.getJSONArray("content")
    
    for(i <- 0 until submissions.length()) {
      val submission: JSONObject = submissions.getJSONObject(i)
      
      val result: JSONObject = client.deleteSubmission(submission.getLong("id"))
      
      println(submission.getLong("id") + " deleted.")
    }

  }
}

First the JotForm class is included from the jotform-api-scala/JotForm.scala file. This class provides access to JotForm's API. You have to create an API client instance with your API key. In case of an exception (wrong authentication etc.), you can catch it or let it fail with a fatal error.

jotform-api-scala's People

Contributors

appaky avatar eeertekin avatar elifceren avatar umutbugrahan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.