Skip to content

Commit b1b94d4

Browse files
committed
refactor: use apiKey instead of key
1 parent 7658e2d commit b1b94d4

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

example/src/initialize.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { configure } from '@provenance/react-native-provenance';
33
if (process.env.EXPO_PUBLIC_API_KEY && process.env.EXPO_PUBLIC_BUNDLE_ID) {
44
configure({
55
apiHost: process.env.EXPO_PUBLIC_API_HOST,
6-
key: process.env.EXPO_PUBLIC_API_KEY,
6+
apiKey: process.env.EXPO_PUBLIC_API_KEY,
77
bundleId: process.env.EXPO_PUBLIC_BUNDLE_ID,
88
});
99
} else {

src/__tests__/api/index.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ global.console = {
1010
};
1111

1212
const sampleApiKey = 'test-api-key';
13-
configure({ key: sampleApiKey, bundleId: 'a-bundle-id', apiHost: 'staging' });
13+
configure({
14+
apiKey: sampleApiKey,
15+
bundleId: 'a-bundle-id',
16+
apiHost: 'staging',
17+
});
1418

1519
describe('getOffers', () => {
1620
beforeEach(() => {

src/__tests__/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ global.console = {
2121

2222
describe('TrustBadge', () => {
2323
configure({
24-
key: 'test-api-key',
24+
apiKey: 'test-api-key',
2525
bundleId: 'fakeBundleId',
2626
apiHost: 'staging',
2727
});

src/__tests__/services/Errors.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Errors', () => {
2222
describe('when onError callback configured', () => {
2323
it('passes the error to the callback', () => {
2424
const onError = jest.fn();
25-
configure({ onError, key: 'a-key', bundleId: 'a-bundle' });
25+
configure({ onError, apiKey: 'a-key', bundleId: 'a-bundle' });
2626
Errors.handle(anError);
2727

2828
expect(onError).toHaveBeenCalledWith(anError);

src/api/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export function getClientHeaders() {
2727
type ApiHost = 'staging' | 'production' | string;
2828

2929
type ConfigurationOptions = {
30-
key: string;
30+
apiKey: string;
3131
bundleId: string;
3232
apiHost?: ApiHost;
3333
onError?: OnErrorCallback;
3434
};
3535

3636
export const configure = (options: ConfigurationOptions) => {
3737
try {
38-
setApiKey(options.key);
38+
setApiKey(options.apiKey);
3939
setBundleId(options.bundleId);
4040

4141
if (options.apiHost) {
@@ -76,7 +76,7 @@ class ProvenanceConfigError extends Error {
7676
function setApiKey(key: string) {
7777
if (!key?.trim())
7878
throw new ProvenanceConfigError(
79-
'"key" is missing. Please provide API key.'
79+
'"apiKey" is missing in `configure` call. Please provide API key.'
8080
);
8181

8282
apiKey = key;
@@ -85,7 +85,7 @@ function setApiKey(key: string) {
8585
function setBundleId(bundleIdValue: string) {
8686
if (!bundleIdValue?.trim())
8787
throw new ProvenanceConfigError(
88-
'"bundleId" is missing. Please provide valid Bundle Id'
88+
'"bundleId" is missing in `configure` call. Please provide valid Bundle Id'
8989
);
9090

9191
bundleId = bundleIdValue;

0 commit comments

Comments
 (0)