Usabilla-Java-Client

Usabilla Java Client

License

License

Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

com.github.pankajkrastogi
ArtifactId

ArtifactId

usabilla-java-client
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Usabilla-Java-Client
Usabilla Java Client
Project URL

Project URL

https://github.com/pankajkrastogi/usabilla-java-client
Source Code Management

Source Code Management

https://github.com/pankajkrastogi/usabilla-java-client

Download usabilla-java-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.pankajkrastogi/usabilla-java-client/ -->
<dependency>
    <groupId>com.github.pankajkrastogi</groupId>
    <artifactId>usabilla-java-client</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.pankajkrastogi/usabilla-java-client/
implementation 'com.github.pankajkrastogi:usabilla-java-client:1.0.2'
// https://jarcasting.com/artifacts/com.github.pankajkrastogi/usabilla-java-client/
implementation ("com.github.pankajkrastogi:usabilla-java-client:1.0.2")
'com.github.pankajkrastogi:usabilla-java-client:jar:1.0.2'
<dependency org="com.github.pankajkrastogi" name="usabilla-java-client" rev="1.0.2">
  <artifact name="usabilla-java-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.pankajkrastogi', module='usabilla-java-client', version='1.0.2')
)
libraryDependencies += "com.github.pankajkrastogi" % "usabilla-java-client" % "1.0.2"
[com.github.pankajkrastogi/usabilla-java-client "1.0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.9
commons-codec : commons-codec jar 1.13
org.apache.httpcomponents : httpclient jar 4.5.10
org.apache.logging.log4j : log4j-core jar 2.12.1

test (6)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.9.10
commons-io : commons-io jar 2.6
org.junit.jupiter : junit-jupiter-engine jar 5.3.1
org.mockito : mockito-core jar 2.21.0
org.mockito : mockito-junit-jupiter jar 2.23.0
org.skyscreamer : jsonassert jar 1.5.0

Project Modules

There are no modules declared in this project.

Java client for Usabilla API

#Usage

Example code to build Auth Token

 class Test {
    void buildRequestCommand() throws InvalidKeyException, NoSuchAlgorithmException {
        final UsabillaAuthBuilder usabillaAuthBuilder = new UsabillaAuthBuilder("mySecret", "myAccessKey");
 
        final LocalDateTime localDateTime = LocalDateTime.of(2019, 9, 19, 16, 52, 21, 10);
        final ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault());
        final Date currDate = Date.from(zonedDateTime.toInstant());
 
        final String method = HttpMethod.GET.name();
        final String requestUri = CommonUtils.BUTTONS_URI;
        final String queryString = "limit=10&since=1568714350000";
 
        RequestCommand requestCommand = usabillaAuthBuilder.buildRequestCommand(currDate, method, requestUri, queryString);
    }
 }

Example code to get all feedback buttons

    class Test {
        void getAllButtons() throws Exception {
            long since = 1571155433000L;
            int limit = 10;
    
            final Date currDate = new Date(since);
            final String method = HttpMethod.GET.name();
            final String requestUri = CommonUtils.BUTTONS_URI;
            final String queryString = String.format("limit=%s&since=%s", limit, since);
    
            final RequestCommand requestCommand = usabillaAuthBuilder.buildRequestCommand(currDate, method, requestUri, queryString);
            final String allFeedbackButtonsJson = usabillaApiService.getAllFeedbackButtons(requestCommand);
        }
    }

Example response for get all feedback buttons

{
  "items":[
    {
      "id":"5dc1a2d9b2461d5fa81533b6",
      "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36",
      "comment":"Good collection of article on homepage ",
      "commentTranslated":"",
      "commentTranslatedFrom":"",
      "location":"",
      "browser":{
        "name":"Chrome",
        "version":"78.0.3904.87",
        "os":"MacOSX",
        "devicetype":"Desktop"
      },
      "date":"2019-11-05T16:27:06.005Z",
      "custom":{
        "accessType":"ae:REG_ONLINE_REGISTERED",
        "accountId":"ae:593",
        "feedback_category":"opt1"
      },
      "email":"",
      "image":"",
      "labels":[
        "compliment"
      ],
      "nps":0,
      "publicUrl":null,
      "rating":4,
      "buttonId":"button5056",
      "tags":[

      ],
      "url":"https://xxx.com/",
      "Bucket":""
    }
   ]
}

Example code to get feedback on given button

    class Test {
        void getAllButtons() throws Exception {
            long since = 1571155433000L;
            int limit = 10;
            String buttonId = "button5056";
    
            final Date currDate = new Date(since);
            final String method = HttpMethod.GET.name();
            final String requestUri = BUTTONS_URI + "/" + buttonId + "/feedback";
            final String queryString = String.format("limit=%s&since=%s", limit, since);
    
            final RequestCommand requestCommand = usabillaAuthBuilder.buildRequestCommand(currDate, method, requestUri, queryString);
            String feedbackJson = usabillaApiService.getFeedbackOnButton(requestCommand);
        }
    }

Example response for get feedback on given button

{
  "items":[
    {
      "id":"d84c9fdb7c8b",
      "name":"Feedback Button"
    },
    {
      "id":"7fb2bbcd20b7",
      "name":"Suggestion Button"
    }
  ],
  "count":2,
  "hasMore":false,
  "lastTimestamp":0
}

Versions

Version
1.0.2
1.0.0