Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVEXP-574: Conversation credentials refining #146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.sinch.sdk.domains.conversation.models.v1.credentials;

public interface ChannelCredentials {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.sinch.sdk.domains.conversation.models.v1.credentials;

import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel;

public class ConversationChannelCredentialsBuilderFactory {

public static ConversationChannelCredentials.Builder appleBc(
AppleBusinessChatCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.APPLEBC)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder instagram(InstagramCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.INSTAGRAM)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder kakaoTalk(KakaoTalkCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.KAKAOTALK)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder kakaoTalkChat(
KakaoTalkChatCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.KAKAOTALKCHAT)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder line(LineCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.LINE)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder messenger(
StaticTokenCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.MESSENGER)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder mms(MMSCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.MMS)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder rcs(StaticBearerCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.RCS)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder sms(StaticBearerCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.SMS)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder telegram(TelegramCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.TELEGRAM)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder viber(StaticTokenCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.VIBER)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder viberBm(
StaticBearerCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.VIBERBM)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder weChat(WeChatCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.WECHAT)
.setCredentials(credentials);
}

public static ConversationChannelCredentials.Builder whatsApp(
StaticBearerCredentials credentials) {
return ConversationChannelCredentials.builder()
.setChannel(ConversationChannel.WHATSAPP)
.setCredentials(credentials);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package com.sinch.sdk.domains.conversation.models.v1.credentials;

import static org.junit.jupiter.api.Assertions.*;

import com.sinch.sdk.core.TestHelpers;
import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel;
import org.junit.jupiter.api.Test;

class ConversationChannelCredentialsBuilderFactoryTest {

@Test
void appleBc() {
AppleBusinessChatCredentials credentials = AppleBusinessChatCredentials.builder().build();
asein-sinch marked this conversation as resolved.
Show resolved Hide resolved
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.appleBc(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.APPLEBC);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void instagram() {
InstagramCredentials credentials = InstagramCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.instagram(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.INSTAGRAM);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void kakaoTalk() {
KakaoTalkCredentials credentials = KakaoTalkCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.kakaoTalk(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.KAKAOTALK);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void kakaoTalkChat() {
KakaoTalkChatCredentials credentials = KakaoTalkChatCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.kakaoTalkChat(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.KAKAOTALKCHAT);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void line() {
LineCredentials credentials = LineCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.line(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.LINE);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void messenger() {
StaticTokenCredentials credentials = StaticTokenCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.messenger(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.MESSENGER);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void mms() {
MMSCredentials credentials = MMSCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.mms(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.MMS);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void rcs() {
StaticBearerCredentials credentials = StaticBearerCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.rcs(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.RCS);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void sms() {
StaticBearerCredentials credentials = StaticBearerCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.sms(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.SMS);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void telegram() {
TelegramCredentials credentials = TelegramCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.telegram(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.TELEGRAM);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void viber() {
StaticTokenCredentials credentials = StaticTokenCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.viber(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.VIBER);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void viberBm() {
StaticBearerCredentials credentials = StaticBearerCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.viberBm(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.VIBERBM);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void weChat() {
WeChatCredentials credentials = WeChatCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.weChat(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.WECHAT);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}

@Test
void whatsApp() {
StaticBearerCredentials credentials = StaticBearerCredentials.builder().build();
ConversationChannelCredentials conversationChannelCredentials =
ConversationChannelCredentialsBuilderFactory.whatsApp(credentials).build();

assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.WHATSAPP);
TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import com.sinch.sdk.domains.conversation.models.v1.app.ConversationMetadataReportView;
import com.sinch.sdk.domains.conversation.models.v1.app.request.AppCreateRequest;
import com.sinch.sdk.domains.conversation.models.v1.app.request.AppUpdateRequest;
import com.sinch.sdk.domains.conversation.models.v1.app.request.ConversationChannelCredentialRequest;
import com.sinch.sdk.domains.conversation.models.v1.app.request.ConversationChannelCredentialsRequestBuilderFactory;
import com.sinch.sdk.domains.conversation.models.v1.app.response.AppResponse;
import com.sinch.sdk.domains.conversation.models.v1.credentials.ChannelIntegrationStatus;
import com.sinch.sdk.domains.conversation.models.v1.credentials.ConversationChannelCredentials;
import com.sinch.sdk.domains.conversation.models.v1.credentials.ConversationChannelCredentialsBuilderFactory;
import com.sinch.sdk.domains.conversation.models.v1.credentials.StaticBearerCredentials;
import com.sinch.sdk.e2e.Config;
import io.cucumber.java.en.Given;
Expand Down Expand Up @@ -41,8 +41,8 @@ public void create() {
String token = "00112233445566778899aabbccddeeff";
String displayName = "E2E Conversation App";

ConversationChannelCredentialRequest credentials =
ConversationChannelCredentialsRequestBuilderFactory.sms(
ConversationChannelCredentials credentials =
ConversationChannelCredentialsBuilderFactory.sms(
StaticBearerCredentials.builder()
.setClaimedIdentity(identity)
.setToken(token)
Expand Down
Loading
Loading