diff --git a/src/main/java/com/squarelabs/shoutout/sdk/sample/ActivityRecordPost.java b/src/main/java/com/squarelabs/shoutout/sdk/sample/ActivityRecordPost.java new file mode 100644 index 0000000..9831624 --- /dev/null +++ b/src/main/java/com/squarelabs/shoutout/sdk/sample/ActivityRecordPost.java @@ -0,0 +1,62 @@ +package com.squarelabs.shoutout.sdk.sample; + +import com.squarelabs.shoutout.sdk.ApiClient; +import com.squarelabs.shoutout.sdk.Configuration; +import com.squarelabs.shoutout.sdk.api.ActivitiesApi; +import com.squarelabs.shoutout.sdk.auth.ApiKeyAuth; +import com.squarelabs.shoutout.sdk.model.ActivityRecord; +import com.squarelabs.shoutout.sdk.model.Response; + +/** + * Created by Madura on 14/07/2016. + */ +public class ActivityRecordPost { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + // Configure API key authorization: ShoutOUTCustomAuthorizer + ApiKeyAuth ShoutOUTCustomAuthorizer = (ApiKeyAuth) defaultClient.getAuthentication("ShoutOUTCustomAuthorizer"); + ShoutOUTCustomAuthorizer.setApiKeyPrefix("Apikey"); + ShoutOUTCustomAuthorizer.setApiKey("YOUR API KEY");//Set Api Token + + try { + ActivitiesApi api = new ActivitiesApi(); + ActivityRecord activityRecord = new ActivityRecord(); + activityRecord.setActivityId("ACTIVITY_ID"); + activityRecord.setActivityName("ACTIVITY_NAME"); + activityRecord.setUserId("USER_ID");//your userId + activityRecord.setActivityData(new ActivityData("signup","John")); + Response response = api.createActivity(activityRecord,ShoutOUTCustomAuthorizer.getApiKey()); + //Do your stuff with the response + System.out.println("Message:"+response.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //Arbitrary object based on the attributes in the event you created + public static class ActivityData { + private String status,name;//arbitrary properties + + public ActivityData(String status, String name) { + this.status = status; + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } +} diff --git a/src/main/java/com/squarelabs/shoutout/sdk/sample/MessagePost.java b/src/main/java/com/squarelabs/shoutout/sdk/sample/MessagePost.java new file mode 100644 index 0000000..f74d936 --- /dev/null +++ b/src/main/java/com/squarelabs/shoutout/sdk/sample/MessagePost.java @@ -0,0 +1,44 @@ +package com.squarelabs.shoutout.sdk.sample; + + +import com.squarelabs.shoutout.sdk.ApiClient; +import com.squarelabs.shoutout.sdk.Configuration; +import com.squarelabs.shoutout.sdk.api.MessagesApi; +import com.squarelabs.shoutout.sdk.auth.ApiKeyAuth; +import com.squarelabs.shoutout.sdk.model.Message; +import com.squarelabs.shoutout.sdk.model.MessageContent; +import com.squarelabs.shoutout.sdk.model.MessageResponse; + +import java.util.Arrays; + +/** + * Created by Madura on 14/07/2016. + */ +public class MessagePost { + + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + // Configure API key authorization: ShoutOUTCustomAuthorizer + ApiKeyAuth ShoutOUTCustomAuthorizer = (ApiKeyAuth) defaultClient.getAuthentication("ShoutOUTCustomAuthorizer"); + ShoutOUTCustomAuthorizer.setApiKeyPrefix("Apikey"); + ShoutOUTCustomAuthorizer.setApiKey("YOUR API KEY");//Set Api Token + + try { + MessagesApi api = new MessagesApi(); + Message message = new Message(); + MessageContent messageContent = new MessageContent(); + messageContent.setSms("Hello, This is a test message"); //sms content + message.setContent(messageContent); + message.setDestinations(Arrays.asList("94778845713"));//mobile numbers to send the message + message.setSource("ShoutDEMO");//Sender Id + message.setTransports(Arrays.asList(Message.TransportsEnum.SMS));//Type of transport (SMS). More transports will come soon + + MessageResponse response = api.sendMessage(ShoutOUTCustomAuthorizer.getApiKey(), message); + //Do your stuff with the response + System.out.println("Status:" + response.getStatus()); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/squarelabs/shoutout/sdk/sample/pom.xml b/src/main/java/com/squarelabs/shoutout/sdk/sample/pom.xml new file mode 100644 index 0000000..e96249b --- /dev/null +++ b/src/main/java/com/squarelabs/shoutout/sdk/sample/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + com.squarelabs.shoutout.sdk.sample + sdk-sample + 1.0 + + + com.squarelabs.shoutout.sdk + shoutout-java-sdk + 7.0.0 + + + \ No newline at end of file