imToken v20.9.11.17版本的 MD5 值为:f7135d2ec367bd3b61d8914bc13d03cb
以下内容为反编译后的 MockChatApiClient.java 源代码,内容仅作参考
package com.helpscout.beacon.internal.data.remote.chat;
import android.content.res.AssetManager;
import androidx.core.app.NotificationCompat;
import androidx.exifinterface.media.ExifInterface;
import com.brentvatne.react.ReactVideoViewManager;
import com.facebook.common.util.UriUtil;
import com.helpscout.beacon.a.a.a;
import com.helpscout.beacon.internal.data.extensions.DateExtensionsKt;
import com.helpscout.beacon.internal.domain.model.BeaconAgent;
import com.helpscout.beacon.internal.domain.model.TimelineEvent;
import com.sensorsdata.analytics.android.sdk.data.DbParams;
import com.squareup.moshi.Types;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import kotlin.Metadata;
import kotlin.NotImplementedError;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.collections.MapsKt;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.Typography;
import kotlinx.coroutines.DelayKt;
import okio.BufferedSource;
import okio.Okio;
import org.bitcoinj.uri.BitcoinURI;
import timber.log.Timber;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0080\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0000\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010>\u001a\u00020=\u0012\u0006\u0010A\u001a\u00020@¢\u0006\u0004\bC\u0010DJ-\u0010\u0007\u001a\u0004\u0018\u00018\u0000\"\u0004\b\u0000\u0010\u00022\u0006\u0010\u0004\u001a\u00020\u00032\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00028\u00000\u0005H\u0002¢\u0006\u0004\b\u0007\u0010\bJ\u0017\u0010\u000b\u001a\u00020\n2\u0006\u0010\t\u001a\u00020\u0003H\u0002¢\u0006\u0004\b\u000b\u0010\fJ\u000f\u0010\u000e\u001a\u00020\rH\u0002¢\u0006\u0004\b\u000e\u0010\u000fJ\u000f\u0010\u0010\u001a\u00020\rH\u0002¢\u0006\u0004\b\u0010\u0010\u000fJ\u0013\u0010\u0012\u001a\u00020\u0011H\u0082@ø\u0001\u0000¢\u0006\u0004\b\u0012\u0010\u0013JQ\u0010\u001c\u001a\u00020\n2\u0006\u0010\u0014\u001a\u00020\u00032\u0006\u0010\u0015\u001a\u00020\u00032\f\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u00170\u00162\b\u0010\u0019\u001a\u0004\u0018\u00010\u00032\u0014\u0010\u001b\u001a\u0010\u0012\u0004\u0012\u00020\u0003\u0012\u0004\u0012\u00020\u0003\u0018\u00010\u001aH\u0096@ø\u0001\u0000¢\u0006\u0004\b\u001c\u0010\u001dJ#\u0010!\u001a\u00020 2\u0006\u0010\u0014\u001a\u00020\u00032\u0006\u0010\u001f\u001a\u00020\u001eH\u0096@ø\u0001\u0000¢\u0006\u0004\b!\u0010\"J\u001b\u0010#\u001a\u00020\n2\u0006\u0010\u0014\u001a\u00020\u0003H\u0096@ø\u0001\u0000¢\u0006\u0004\b#\u0010$J9\u0010(\u001a\u00020\n2\u0006\u0010\u0014\u001a\u00020\u00032\u0006\u0010%\u001a\u00020\u00032\u0006\u0010&\u001a\u00020\u00032\f\u0010'\u001a\b\u0012\u0004\u0012\u00020\u001e0\u0016H\u0096@ø\u0001\u0000¢\u0006\u0004\b(\u0010)J\u0013\u0010*\u001a\u00020\nH\u0096@ø\u0001\u0000¢\u0006\u0004\b*\u0010\u0013J\u001b\u0010,\u001a\u00020 2\u0006\u0010+\u001a\u00020\u0003H\u0096@ø\u0001\u0000¢\u0006\u0004\b,\u0010$J\u0019\u0010-\u001a\b\u0012\u0004\u0012\u00020 0\u0016H\u0096@ø\u0001\u0000¢\u0006\u0004\b-\u0010\u0013J\u0019\u0010/\u001a\b\u0012\u0004\u0012\u00020.0\u0016H\u0096@ø\u0001\u0000¢\u0006\u0004\b/\u0010\u0013J+\u00103\u001a\u000e\u0012\u0004\u0012\u00020\u0003\u0012\u0004\u0012\u0002020\u001a2\u0006\u00100\u001a\u00020\u00032\u0006\u00101\u001a\u00020\u0003H\u0016¢\u0006\u0004\b3\u00104J\u0013\u00105\u001a\u00020\rH\u0096@ø\u0001\u0000¢\u0006\u0004\b5\u0010\u0013J\u0013\u00107\u001a\u000206H\u0096@ø\u0001\u0000¢\u0006\u0004\b7\u0010\u0013J%\u0010;\u001a\u00020\u00112\u0006\u00109\u001a\u0002082\b\u0010:\u001a\u0004\u0018\u00010\u0003H\u0096@ø\u0001\u0000¢\u0006\u0004\b;\u0010<R\u0016\u0010>\u001a\u00020=8\u0002@\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b>\u0010?R\u0016\u0010A\u001a\u00020@8\u0002@\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bA\u0010B\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006E"}, d2 = {"Lcom/helpscout/beacon/internal/data/remote/chat/MockChatApiClient;", "Lcom/helpscout/beacon/internal/data/remote/chat/ChatApiClient;", ExifInterface.GPS_DIRECTION_TRUE, "", UriUtil.LOCAL_FILE_SCHEME, "Ljava/lang/Class;", ReactVideoViewManager.PROP_SRC_TYPE, "readFileAs", "(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;", "id", "Lcom/helpscout/beacon/internal/data/remote/chat/ChatEnvelopeApi;", "mockChatEnvelope", "(Ljava/lang/String;)Lcom/helpscout/beacon/internal/data/remote/chat/ChatEnvelopeApi;", "Lcom/helpscout/beacon/internal/data/remote/chat/UserApi;", "mockCustomer", "()Lcom/helpscout/beacon/internal/data/remote/chat/UserApi;", "sampleAgentAuthor", "", "waitABit", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "chatId", "firstMessage", "", "Lcom/helpscout/beacon/internal/domain/model/TimelineEvent;", DbParams.TABLE_EVENTS, "deviceId", "", "sessionAttributes", "startChat", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/util/Map;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Lcom/helpscout/beacon/internal/data/remote/chat/ChatAttachmentApi;", "attachmentApi", "Lcom/helpscout/beacon/internal/data/remote/chat/ChatEventApi;", "addAttachment", "(Ljava/lang/String;Lcom/helpscout/beacon/internal/data/remote/chat/ChatAttachmentApi;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "getChat", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "messageId", BitcoinURI.FIELD_MESSAGE, "attachments", "addMessage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "endChat", "eventId", "getChatEvent", "getAllChatEvents", "Lcom/helpscout/beacon/internal/domain/model/BeaconAgent;", "getAvailableAgents", "socketId", "channelName", "Lcom/helpscout/beacon/internal/data/remote/chat/RealtimeChannelApi;", "pusherAuth", "(Ljava/lang/String;Ljava/lang/String;)Ljava/util/Map;", "sendBeaconClosedEvent", "", "getMessageEventCount", "", "rating", "comments", "rateChat", "(ILjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Landroid/content/res/AssetManager;", "assetManager", "Landroid/content/res/AssetManager;", "Lcom/helpscout/beacon/a/a/a;", "parser", "Lcom/helpscout/beacon/a/a/a;", "<init>", "(Landroid/content/res/AssetManager;Lcom/helpscout/beacon/a/a/a;)V", "beacon_release"}, k = 1, mv = {1, 4, 2})
public final class MockChatApiClient implements ChatApiClient {
private final AssetManager assetManager;
private final a parser;
public MockChatApiClient(AssetManager assetManager, a parser) {
Intrinsics.checkNotNullParameter(assetManager, "assetManager");
Intrinsics.checkNotNullParameter(parser, "parser");
this.assetManager = assetManager;
this.parser = parser;
}
private final ChatEnvelopeApi mockChatEnvelope(String str) {
return new ChatEnvelopeApi(str, DateExtensionsKt.nowUTCFormattedToApi(), DateExtensionsKt.nowUTCFormattedToApi(), "", null, mockCustomer(), CollectionsKt.listOf((Object[]) new String[]{"pusher-private-55494", "pusher-presence-55494"}));
}
private final UserApi mockCustomer() {
return new UserApi(213L, AuthorType.customer, "Boom broom", "PH", "");
}
private final <T> T readFileAs(String str, Class<T> cls) {
BufferedSource bufferedSource;
T t = (T) false;
try {
InputStream open = this.assetManager.open("json/" + str + ".json");
Intrinsics.checkNotNullExpressionValue(open, "assetManager.open(\"json/$file.json\")");
bufferedSource = Okio.buffer(Okio.source(open));
try {
t = this.parser.a(cls).a(bufferedSource);
} catch (IOException unused) {
} catch (Throwable th) {
th = th;
t = (T) bufferedSource;
if (t != 0) {
try {
t.close();
} catch (IOException e) {
e.printStackTrace();
}
}
throw th;
}
} catch (IOException unused2) {
bufferedSource = null;
} catch (Throwable th2) {
th = th2;
}
return (T) t;
}
private final UserApi sampleAgentAuthor() {
return new UserApi(2L, AuthorType.agent, "foo", "SA", "https://d33v4339jhl8k0.cloudfront.net/users/145996.175833.jpg");
}
@Override
public Object addAttachment(String str, ChatAttachmentApi chatAttachmentApi, Continuation<? super ChatEventApi> continuation) {
throw new NotImplementedError("An operation is not implemented: AddAttachment not mocked!");
}
@Override
public Object addMessage(String str, String str2, String str3, List<ChatAttachmentApi> list, Continuation<? super ChatEnvelopeApi> continuation) {
MockChatApiClient$addMessage$1 mockChatApiClient$addMessage$1;
int i;
MockChatApiClient mockChatApiClient;
if (continuation instanceof MockChatApiClient$addMessage$1) {
mockChatApiClient$addMessage$1 = (MockChatApiClient$addMessage$1) continuation;
int i2 = mockChatApiClient$addMessage$1.label;
if ((i2 & Integer.MIN_VALUE) != 0) {
mockChatApiClient$addMessage$1.label = i2 - Integer.MIN_VALUE;
Object obj = mockChatApiClient$addMessage$1.result;
Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$addMessage$1.label;
if (i != 0) {
ResultKt.throwOnFailure(obj);
Timber.d("Uploading message: \"" + str3 + Typography.quote, new Object[0]);
mockChatApiClient$addMessage$1.L$0 = this;
mockChatApiClient$addMessage$1.L$1 = str;
mockChatApiClient$addMessage$1.label = 1;
if (waitABit(mockChatApiClient$addMessage$1) == coroutine_suspended) {
return coroutine_suspended;
}
mockChatApiClient = this;
} else if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
str = (String) mockChatApiClient$addMessage$1.L$1;
mockChatApiClient = (MockChatApiClient) mockChatApiClient$addMessage$1.L$0;
ResultKt.throwOnFailure(obj);
}
return mockChatApiClient.mockChatEnvelope(str);
}
}
mockChatApiClient$addMessage$1 = new MockChatApiClient$addMessage$1(this, continuation);
Object obj2 = mockChatApiClient$addMessage$1.result;
Object coroutine_suspended2 = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$addMessage$1.label;
if (i != 0) {
}
return mockChatApiClient.mockChatEnvelope(str);
}
@Override
public Object endChat(Continuation<? super ChatEnvelopeApi> continuation) {
MockChatApiClient$endChat$1 mockChatApiClient$endChat$1;
int i;
MockChatApiClient mockChatApiClient;
if (continuation instanceof MockChatApiClient$endChat$1) {
mockChatApiClient$endChat$1 = (MockChatApiClient$endChat$1) continuation;
int i2 = mockChatApiClient$endChat$1.label;
if ((i2 & Integer.MIN_VALUE) != 0) {
mockChatApiClient$endChat$1.label = i2 - Integer.MIN_VALUE;
Object obj = mockChatApiClient$endChat$1.result;
Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$endChat$1.label;
if (i != 0) {
ResultKt.throwOnFailure(obj);
Timber.d("Ending chat on server", new Object[0]);
mockChatApiClient$endChat$1.L$0 = this;
mockChatApiClient$endChat$1.label = 1;
if (waitABit(mockChatApiClient$endChat$1) == coroutine_suspended) {
return coroutine_suspended;
}
mockChatApiClient = this;
} else if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
mockChatApiClient = (MockChatApiClient) mockChatApiClient$endChat$1.L$0;
ResultKt.throwOnFailure(obj);
}
return ChatEnvelopeApi.copy$default(mockChatApiClient.mockChatEnvelope("FOOBAR"), null, null, null, DateExtensionsKt.nowUTCFormattedToApi(), null, null, null, 119, null);
}
}
mockChatApiClient$endChat$1 = new MockChatApiClient$endChat$1(this, continuation);
Object obj2 = mockChatApiClient$endChat$1.result;
Object coroutine_suspended2 = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$endChat$1.label;
if (i != 0) {
}
return ChatEnvelopeApi.copy$default(mockChatApiClient.mockChatEnvelope("FOOBAR"), null, null, null, DateExtensionsKt.nowUTCFormattedToApi(), null, null, null, 119, null);
}
@Override
public Object getAllChatEvents(Continuation<? super List<ChatEventApi>> continuation) {
return CollectionsKt.emptyList();
}
@Override
public Object getAvailableAgents(Continuation<? super List<BeaconAgent>> continuation) {
UserApi sampleAgentAuthor = sampleAgentAuthor();
Integer boxInt = Boxing.boxInt(1);
String displayName = sampleAgentAuthor.getDisplayName();
String initials = sampleAgentAuthor.getInitials();
if (initials == null) {
initials = "MK";
}
return CollectionsKt.listOf(new BeaconAgent(boxInt, displayName, initials, sampleAgentAuthor.getPhoto()));
}
@Override
public Object getChat(String str, Continuation<? super ChatEnvelopeApi> continuation) {
MockChatApiClient$getChat$1 mockChatApiClient$getChat$1;
int i;
MockChatApiClient mockChatApiClient;
if (continuation instanceof MockChatApiClient$getChat$1) {
mockChatApiClient$getChat$1 = (MockChatApiClient$getChat$1) continuation;
int i2 = mockChatApiClient$getChat$1.label;
if ((i2 & Integer.MIN_VALUE) != 0) {
mockChatApiClient$getChat$1.label = i2 - Integer.MIN_VALUE;
Object obj = mockChatApiClient$getChat$1.result;
Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$getChat$1.label;
if (i != 0) {
ResultKt.throwOnFailure(obj);
mockChatApiClient$getChat$1.L$0 = this;
mockChatApiClient$getChat$1.L$1 = str;
mockChatApiClient$getChat$1.label = 1;
if (waitABit(mockChatApiClient$getChat$1) == coroutine_suspended) {
return coroutine_suspended;
}
mockChatApiClient = this;
} else if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
str = (String) mockChatApiClient$getChat$1.L$1;
mockChatApiClient = (MockChatApiClient) mockChatApiClient$getChat$1.L$0;
ResultKt.throwOnFailure(obj);
}
return mockChatApiClient.mockChatEnvelope(str);
}
}
mockChatApiClient$getChat$1 = new MockChatApiClient$getChat$1(this, continuation);
Object obj2 = mockChatApiClient$getChat$1.result;
Object coroutine_suspended2 = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$getChat$1.label;
if (i != 0) {
}
return mockChatApiClient.mockChatEnvelope(str);
}
@Override
public Object getChatEvent(String str, Continuation<? super ChatEventApi> continuation) {
ChatEventApi chatEventApi = (ChatEventApi) readFileAs(NotificationCompat.CATEGORY_EVENT, ChatEventApi.class);
Intrinsics.checkNotNull(chatEventApi);
return ChatEventApi.copy$default(chatEventApi, str, null, null, null, null, null, null, 126, null);
}
@Override
public Object getMessageEventCount(Continuation<? super Long> continuation) {
return Boxing.boxLong(10L);
}
@Override
public Map<String, RealtimeChannelApi> pusherAuth(String socketId, String channelName) {
Intrinsics.checkNotNullParameter(socketId, "socketId");
Intrinsics.checkNotNullParameter(channelName, "channelName");
Types.newParameterizedType(Map.class, String.class, RealtimeChannelApi.class);
return MapsKt.emptyMap();
}
@Override
public Object rateChat(int i, String str, Continuation<? super Unit> continuation) {
return Unit.INSTANCE;
}
@Override
public Object sendBeaconClosedEvent(Continuation<? super UserApi> continuation) {
return new UserApi(Boxing.boxLong(1L), AuthorType.customer, null, null, null);
}
@Override
public Object startChat(String str, String str2, List<? extends TimelineEvent> list, String str3, Map<String, String> map, Continuation<? super ChatEnvelopeApi> continuation) {
MockChatApiClient$startChat$1 mockChatApiClient$startChat$1;
int i;
MockChatApiClient mockChatApiClient;
if (continuation instanceof MockChatApiClient$startChat$1) {
mockChatApiClient$startChat$1 = (MockChatApiClient$startChat$1) continuation;
int i2 = mockChatApiClient$startChat$1.label;
if ((i2 & Integer.MIN_VALUE) != 0) {
mockChatApiClient$startChat$1.label = i2 - Integer.MIN_VALUE;
Object obj = mockChatApiClient$startChat$1.result;
Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$startChat$1.label;
if (i != 0) {
ResultKt.throwOnFailure(obj);
Timber.d("Uploading chat with subject: \"" + str2 + Typography.quote, new Object[0]);
mockChatApiClient$startChat$1.L$0 = this;
mockChatApiClient$startChat$1.label = 1;
if (waitABit(mockChatApiClient$startChat$1) == coroutine_suspended) {
return coroutine_suspended;
}
mockChatApiClient = this;
} else if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
mockChatApiClient = (MockChatApiClient) mockChatApiClient$startChat$1.L$0;
ResultKt.throwOnFailure(obj);
}
Object readFileAs = mockChatApiClient.readFileAs("chat_envelope", ChatEnvelopeApi.class);
Intrinsics.checkNotNull(readFileAs);
return readFileAs;
}
}
mockChatApiClient$startChat$1 = new MockChatApiClient$startChat$1(this, continuation);
Object obj2 = mockChatApiClient$startChat$1.result;
Object coroutine_suspended2 = IntrinsicsKt.getCOROUTINE_SUSPENDED();
i = mockChatApiClient$startChat$1.label;
if (i != 0) {
}
Object readFileAs2 = mockChatApiClient.readFileAs("chat_envelope", ChatEnvelopeApi.class);
Intrinsics.checkNotNull(readFileAs2);
return readFileAs2;
}
final Object waitABit(Continuation<? super Unit> continuation) {
Object delay = DelayKt.delay(1500L, continuation);
return delay == IntrinsicsKt.getCOROUTINE_SUSPENDED() ? delay : Unit.INSTANCE;
}
}