Skip to content

Commit

Permalink
version 2.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vladd-g committed Aug 6, 2024
2 parents e7578f4 + aaacd10 commit ab5b41c
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 117 deletions.
2 changes: 1 addition & 1 deletion lib/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def getExtOrDefault(name) {
def kotlin_version = getExtOrDefault('kotlinVersion')

dependencies {
api 'io.adapty:android-sdk:2.11.2'
api 'io.adapty:android-sdk:2.11.3'

//noinspection GradleDynamicVersion
api 'io.adapty.internal:crossplatform:2.11.1'
Expand Down
9 changes: 7 additions & 2 deletions lib/src/adapty-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export class Adapty {
body.set('user_id', params.customerUserId);
}
if (params.ipAddressCollectionDisabled) {
body.set('ip_address_collection_disabled', params.ipAddressCollectionDisabled);
body.set(
'ip_address_collection_disabled',
params.ipAddressCollectionDisabled,
);
}
if (logLevel) {
body.set('log_level', logLevel);
Expand Down Expand Up @@ -621,7 +624,9 @@ export class Adapty {
*
* @returns {Promise<void>} resolves when fallback paywalls are saved
*/
public async setFallbackPaywalls(paywallsLocation: Input.FallbackPaywallsLocation): Promise<void> {
public async setFallbackPaywalls(
paywallsLocation: Input.FallbackPaywallsLocation,
): Promise<void> {
const ctx = new LogContext();
const log = ctx.call({ methodName: 'setFallbackPaywalls' });
const paywallsLocationJson = Platform.select({
Expand Down
5 changes: 4 additions & 1 deletion lib/src/coders/adapty-non-subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { DateCoder } from './date';
type Model = AdaptyNonSubscription;
type Serializable = Schema['Output.AdaptyNonSubscription'];

export class AdaptyNonSubscriptionCoder extends SimpleCoder<Model, Serializable> {
export class AdaptyNonSubscriptionCoder extends SimpleCoder<
Model,
Serializable
> {
protected properties: Properties<Model, Serializable> = {
isConsumable: { key: 'is_consumable', required: true, type: 'boolean' },
isRefund: { key: 'is_refund', required: true, type: 'boolean' },
Expand Down
4 changes: 1 addition & 3 deletions lib/src/coders/adapty-paywall-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import type { AdaptyPaywallBuilder } from '@/types';
import type { Schema } from '@/types/schema';

type Model = AdaptyPaywallBuilder;
const mocks: Required<
Schema['InOutput.AdaptyPaywall']
>['paywall_builder'][] = [
const mocks: Required<Schema['InOutput.AdaptyPaywall']>['paywall_builder'][] = [
{
paywall_builder_id: 'paywallBuilder1',
lang: 'en',
Expand Down
7 changes: 5 additions & 2 deletions lib/src/coders/adapty-paywall-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { SimpleCoder } from './coder';

type Model = AdaptyPaywallBuilder;
type Serializable = Required<
Schema['InOutput.AdaptyPaywall']
Schema['InOutput.AdaptyPaywall']
>['paywall_builder'];

export class AdaptyPaywallBuilderCoder extends SimpleCoder<Model, Serializable> {
export class AdaptyPaywallBuilderCoder extends SimpleCoder<
Model,
Serializable
> {
protected properties: Properties<Model, Serializable> = {
id: {
key: 'paywall_builder_id',
Expand Down
5 changes: 4 additions & 1 deletion lib/src/coders/adapty-paywall-product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { AdaptySubscriptionDetailsCoder } from './adapty-subscription-details';
type Model = AdaptyPaywallProduct;
type Serializable = Schema['Output.AdaptyPaywallProduct'];

export class AdaptyPaywallProductCoder extends SimpleCoder<Model, Serializable> {
export class AdaptyPaywallProductCoder extends SimpleCoder<
Model,
Serializable
> {
protected properties: Properties<Model, Serializable> = {
vendorProductId: {
key: 'vendor_product_id',
Expand Down
6 changes: 3 additions & 3 deletions lib/src/coders/adapty-paywall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const mocks: Schema['InOutput.AdaptyPaywall'][] = [
variation_id: 'var001',
paywall_builder: {
paywall_builder_id: 'paywallBuilder1',
lang: 'en'
lang: 'en',
},
},
{
Expand Down Expand Up @@ -70,13 +70,13 @@ function toModel(mock: (typeof mocks)[number]): Model {
name: mock.paywall_name,
products: _products.decode(mock.products),
...(mock.remote_config && {
remoteConfig: _remoteConfig.decode(mock.remote_config)
remoteConfig: _remoteConfig.decode(mock.remote_config),
}),
revision: mock.revision,
variationId: mock.variation_id,
version: mock.response_created_at,
...(mock.paywall_builder && {
paywallBuilder: _paywallBuilder.decode(mock.paywall_builder)
paywallBuilder: _paywallBuilder.decode(mock.paywall_builder),
}),
hasViewConfiguration: mock.paywall_builder !== undefined,
};
Expand Down
11 changes: 9 additions & 2 deletions lib/src/coders/adapty-paywall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ type Model = AdaptyPaywall;
type CodableModel = Omit<Model, 'hasViewConfiguration'>;
type Serializable = Schema['InOutput.AdaptyPaywall'];

export class AdaptyPaywallCoder extends Coder<Model, CodableModel, Serializable> {
export class AdaptyPaywallCoder extends Coder<
Model,
CodableModel,
Serializable
> {
protected properties: Properties<CodableModel, Serializable> = {
abTestName: { key: 'ab_test_name', required: true, type: 'string' },
placementId: { key: 'developer_id', required: true, type: 'string' },
Expand Down Expand Up @@ -43,7 +47,10 @@ export class AdaptyPaywallCoder extends Coder<Model, CodableModel, Serializable>

override decode(data: Serializable): Model {
const codablePart = super.decode(data);
return {...codablePart, hasViewConfiguration: codablePart.paywallBuilder !== undefined };
return {
...codablePart,
hasViewConfiguration: codablePart.paywallBuilder !== undefined,
};
}

override encode(data: Model): Serializable {
Expand Down
5 changes: 4 additions & 1 deletion lib/src/coders/adapty-profile-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { SimpleCoder } from './coder';
type Model = AdaptyProfileParameters;
type Serializable = Schema['Input.AdaptyProfileParameters'];

export class AdaptyProfileParametersCoder extends SimpleCoder<Model, Serializable> {
export class AdaptyProfileParametersCoder extends SimpleCoder<
Model,
Serializable
> {
protected properties: Properties<Model, Serializable> = {
firstName: { key: 'first_name', required: false, type: 'string' },
lastName: { key: 'last_name', required: false, type: 'string' },
Expand Down
4 changes: 1 addition & 3 deletions lib/src/coders/adapty-remote-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import type { AdaptyRemoteConfig } from '@/types';
import type { Schema } from '@/types/schema';

type Model = AdaptyRemoteConfig;
const mocks: Required<
Schema['InOutput.AdaptyPaywall']
>['remote_config'][] = [
const mocks: Required<Schema['InOutput.AdaptyPaywall']>['remote_config'][] = [
{
lang: 'en',
data: '{"key":"value"}', // A custom JSON string configured in Adapty Dashboard
Expand Down
15 changes: 10 additions & 5 deletions lib/src/coders/adapty-remote-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { JSONCoder } from './json';

type Model = AdaptyRemoteConfig;
type CodableModel = Omit<Model, 'dataString'>;
type Serializable = Required<
Schema['InOutput.AdaptyPaywall']
>['remote_config'];
type Serializable = Required<Schema['InOutput.AdaptyPaywall']>['remote_config'];

export class AdaptyRemoteConfigCoder extends Coder<Model, CodableModel, Serializable> {
export class AdaptyRemoteConfigCoder extends Coder<
Model,
CodableModel,
Serializable
> {
protected properties: Properties<CodableModel, Serializable> = {
data: {
key: 'data',
Expand All @@ -28,7 +30,10 @@ export class AdaptyRemoteConfigCoder extends Coder<Model, CodableModel, Serializ
override decode(data: Serializable): Model {
const codablePart = super.decode(data);
const dataString = JSON.stringify(codablePart.data);
return {...codablePart, dataString: dataString.length < 4 ? '' : dataString};
return {
...codablePart,
dataString: dataString.length < 4 ? '' : dataString,
};
}

override encode(data: Model): Serializable {
Expand Down
5 changes: 4 additions & 1 deletion lib/src/coders/adapty-subscription-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ type Serializable = Required<
Schema['Output.AdaptyPaywallProduct']
>['subscription_details'];

export class AdaptySubscriptionDetailsCoder extends SimpleCoder<Model, Serializable> {
export class AdaptySubscriptionDetailsCoder extends SimpleCoder<
Model,
Serializable
> {
protected properties: Properties<Model, Serializable> = {
subscriptionPeriod: {
key: 'subscription_period',
Expand Down
5 changes: 4 additions & 1 deletion lib/src/coders/adapty-subscription-period.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { SimpleCoder } from './coder';
type Model = AdaptySubscriptionPeriod;
type Serializable = Schema['Output.AdaptySubscriptionPeriod'];

export class AdaptySubscriptionPeriodCoder extends SimpleCoder<Model, Serializable> {
export class AdaptySubscriptionPeriodCoder extends SimpleCoder<
Model,
Serializable
> {
protected properties: Properties<Model, Serializable> = {
unit: { key: 'unit', required: true, type: 'string' },
numberOfUnits: { key: 'number_of_units', required: true, type: 'number' },
Expand Down
2 changes: 1 addition & 1 deletion lib/src/coders/coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ export abstract class Coder<
export abstract class SimpleCoder<
Model extends Record<string, any>,
Serializable extends Record<string, any> = Record<string, any>,
> extends Coder<Model, Model, Serializable> {}
> extends Coder<Model, Model, Serializable> {}
Loading

0 comments on commit ab5b41c

Please sign in to comment.