Skip to content

Commit

Permalink
country data API
Browse files Browse the repository at this point in the history
  • Loading branch information
gabitanalla committed Apr 12, 2022
1 parent 4d0afdd commit 1b8044c
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/common/rest/get-countries/index.ts
@@ -0,0 +1,21 @@
import { useLazyAxios } from 'use-axios-client';
import { MethodMetadata } from '..';
import { URL } from '../../helpers/axios';

const path = 'countries';

export function useMethod() {
const [getData, { data, error, loading }] = useLazyAxios({
url: `${URL}${path}`,
});
return { data, error, loading, getData };
}

export const metadata: MethodMetadata = {
author: 'Gabriela Golmar',
authorPicture: '',
description: 'pulls the full list of countries',
name: path,
method: 'GET',
parameters: [],
};
4 changes: 3 additions & 1 deletion src/common/rest/index.ts
Expand Up @@ -2,6 +2,8 @@ import * as auth from './auth';
import * as getClient from './get-user'
import * as postClient from './post-user'
import * as accounts from './accounts';
import * as getCountries from './get-countries'
import * as postCountry from './post-country'

export interface Parameter {
key: number;
Expand All @@ -21,4 +23,4 @@ export interface MethodMetadata {
parameters: Parameter[];
}

export const masaRestClient = { auth, accounts, getClient, postClient };
export const masaRestClient = { auth, accounts, getClient, postClient, getCountries, postCountry };
76 changes: 76 additions & 0 deletions src/common/rest/post-country/index.ts
@@ -0,0 +1,76 @@
import { MethodMetadata, Parameter } from '..';
import { Headers } from '../../helpers/axios';
import { useRestCall } from '../../helpers/rest-calls';

const path = 'country';

export function useMethod({ pathParameters, body }: any) {
const { data, error, loading, getData } = useRestCall({
pathParameters,
headers: Headers,
body,
metadata,
});
return { data, error, loading, getData };
}

const parameters: Parameter[] = [
{
key: 1,
name: 'bankApproved',
description: '',
required: 'yes',
default: '',
},
{
key: 2,
name: 'phoneCode',
description: '',
required: 'yes',
default: '',
},
{
key: 3,
name: 'iso2',
description: '',
required: 'yes',
default: '',
},
{
key: 4,
name: 'iso3',
description: '',
required: 'yes',
default: '',
},
{
key: 5,
name: 'abbreviation',
description: '',
required: 'yes',
default: '',
},
{
key: 6,
name: 'name',
description: '',
required: 'yes',
default: '',
},
{
key: 7,
name: 'version',
description: '',
required: 'yes',
default: '',
},
];

export const metadata: MethodMetadata = {
author: 'Gabriela Golmar',
authorPicture: '',
description: 'upserts a single country record',
name: path,
method: 'POST',
parameters,
};

0 comments on commit 1b8044c

Please sign in to comment.