diff --git a/src/common/rest/get-countries/index.ts b/src/common/rest/get-countries/index.ts new file mode 100644 index 00000000..a928bc05 --- /dev/null +++ b/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: [], +}; \ No newline at end of file diff --git a/src/common/rest/index.ts b/src/common/rest/index.ts index 39e96a03..1c3dab84 100644 --- a/src/common/rest/index.ts +++ b/src/common/rest/index.ts @@ -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; @@ -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 }; diff --git a/src/common/rest/post-country/index.ts b/src/common/rest/post-country/index.ts new file mode 100644 index 00000000..d6d0cc47 --- /dev/null +++ b/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, +}; \ No newline at end of file