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

42matters api method updates #6

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
50 changes: 49 additions & 1 deletion packages/42matters/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ class Api extends ApiKeyRequester {
appleSearch: 'ios/apps/search.json',
appleQuery: 'ios/apps/query.json',
tencentLookup: 'tencent/android/apps/lookup.json',
amazonLookup: 'amazon/android/apps/lookup.json'
amazonLookup: 'amazon/android/apps/lookup.json',
sdks: 'sdks/search.json'
}
this.URLs = {}
this.generateUrls();
// v1 schema json
this.v1BaseUrl = 'https://data.42matters.com/api/';
MichaelRyanWebber marked this conversation as resolved.
Show resolved Hide resolved
this.v1Endpoints = {
androidCountries: 'meta/android/apps/app_countries.json',
iosCountries: 'meta/ios/apps/app_countries.json',
androidCategories: 'meta/android/apps/app_categories.json',
iosCategories: 'meta/ios/apps/app_secondary_genres.json',
}
}

generateUrls() {
Expand Down Expand Up @@ -71,6 +80,45 @@ class Api extends ApiKeyRequester {
return this._get(options);
}

async getGoogleCategories() {
const options = {
url: this.v1BaseUrl + this.v1Endpoints.androidCategories
}
return this._get(options);
}

async getAppleGenres() {
const options = {
url: this.v1BaseUrl + this.v1Endpoints.iosCategories
}
return this._get(options);
}

async getGoogleCountries() {
const options = {
url: this.v1BaseUrl + this.v1Endpoints.androidCountries
}
return this._get(options);
}

async getAppleCountries() {
const options = {
url: this.v1BaseUrl + this.v1Endpoints.iosCountries
}
return this._get(options);
}

async getSDKs() {
const options = {
url: this.URLs.sdks,
query: {
platform: 'all',
q: '*'
}
}
return this._get(options);
}

async getGoogleAppData(packageName) {
const options = {
url: this.URLs.googleLookup,
Expand Down
36 changes: 34 additions & 2 deletions packages/42matters/tests/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,40 @@ describe('42matters API Tests', () => {
});
});

describe('API requests', () => {
describe('App Data requests', () => {
describe('Metadata requests', () => {
it('Should retrieve SDKs', async () => {
const {results: sdks} = await api.getSDKs();
expect(sdks).toBeDefined();
expect(sdks.length).toBeGreaterThan(0);
})

it('Should retrieve Google countries', async () => {
const {countries} = await api.getGoogleCountries();
expect(countries).toBeDefined();
expect(countries.length).toBeGreaterThan(0);
})

it('Should retrieve Apple countries', async () => {
const {countries} = await api.getAppleCountries();
expect(countries).toBeDefined();
expect(countries.length).toBeGreaterThan(0);
})

it('Should retrieve Google categories', async () => {
const {categories} = await api.getGoogleCategories();
expect(categories).toBeDefined();
expect(categories.length).toBeGreaterThan(0);
})

it('Should retrieve Apple categories', async () => {
const {genres} = await api.getAppleGenres();
expect(genres).toBeDefined();
expect(genres.length).toBeGreaterThan(0);
})
})

describe('App Data requests', () => {
describe('Basic requests', () => {
it('Should retrieve an android app', async () => {
const appData = await api.getGoogleAppData('com.facebook.katana');
expect(appData).toBeDefined();
Expand Down
Loading