Code Monkey home page Code Monkey logo

api-sdk-scala's Introduction

Particeep API Client for Scala

You can sign up for a Particeep account at https://admin.particeep.com

Requirements

Java 1.8 or later.

Play dependencies

By default this lib depends on Play framework.

If you don't use Play!, you can checkout the branch https://github.com/Particeep/api-sdk-scala/tree/feature/stand_alone You'll be able to use the lib without bringing all the Play framework into your code base. The dependancies in the stand_alone branch is limited to 2 libraries extracted from Play project.

If you want to use your own json parser and http wrapper, you'll better build everything by yourself

Installation

Sbt users

Add this dependency to your project's POM:

libraryDependencies += "com.particeep" %% "api-scala-client" % "1.0.0"

Or add the project as a dependency

lazy val root = Project("root", file("."))
                    .dependsOn(apiParticeepClient)

lazy val apiParticeepClient = RootProject(uri("https://github.com/Particeep/api-sdk-scala.git"))

Others

You'll need to manually install the following JARs and dependencies :

NB : You also need transitive dependencies of play-ws

Documentation

Please see the Particeep API docs for the most up-to-date documentation.

Usage

ParticeepExample.scala

import com.particeep.api.core._
import com.particeep.api._

object ParticeepExample {

    def basicUsage() {
        val ws = ParticeepApi.test(apiKey, apiSecret)
        val result:Future[Either[JsError, User]] = ws.user.byId("some_user_id")

        // to switch to prod env just do
        val ws_prod = ParticeepApi.prod(apiKey, apiSecret)
    }

    // if you need only a subset of the endpoints of the api and don't want to be
    // bothered with the other you can create a custom client
    def customUsage() {
        val creds = ApiCredential(apiKey, apiSecret)

        // here you have access only to User and Info endpoints
        val ws = new ApiClient(
            baseUrl = "https://api.particeep.com", // prod url
            apiCredential = creds,
            version = "1"
        ) with InfoCapability with UserCapability

        val result:Future[Either[JsError, User]] = ws.user.byId("some_user_id")
    }
}

See the tests for more examples.

If you need to customize the http client, take a look at ApiClient.scala

Testing

You must have Sbt installed. To run the tests:

sbt test

You can run particular tests by using testOnly pkg.ClassName -- -z update. Make sure you use the fully qualified class name to differentiate between unit and functional tests. For example:

sbt "testOnly com.particeep.test.ParticeepTest -- -z update"

api-sdk-scala's People

Contributors

noelasne avatar thavril avatar driox avatar rloth avatar ziaccro avatar alexandreannic avatar yanlinqu avatar

Stargazers

 avatar  avatar Remy-Poirier avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

luintas

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.