UNPKG

@shopify/shopify-api

Version:

Shopify API Library for Node - accelerate development with support for authentication, graphql proxy, webhooks

128 lines (114 loc) 3.5 kB
/*********************************************************************************************************************** * This file is auto-generated. If you have an issue, please create a GitHub issue. * ***********************************************************************************************************************/ import {Base, FindAllResponse} from '../../base'; import {ResourcePath, ResourceNames} from '../../types'; import {Session} from '../../../lib/session/session'; import {ApiVersion} from '../../../lib/types'; import {Province} from './province'; interface FindArgs { session: Session; id: number | string; fields?: unknown; } interface DeleteArgs { session: Session; id: number | string; } interface AllArgs { [key: string]: unknown; session: Session; since_id?: unknown; fields?: unknown; } interface CountArgs { [key: string]: unknown; session: Session; } export class Country extends Base { public static apiVersion = ApiVersion.July25; protected static hasOne: {[key: string]: typeof Base} = {}; protected static hasMany: {[key: string]: typeof Base} = { "provinces": Province }; protected static paths: ResourcePath[] = [ {"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "countries/<id>.json"}, {"http_method": "get", "operation": "count", "ids": [], "path": "countries/count.json"}, {"http_method": "get", "operation": "get", "ids": [], "path": "countries.json"}, {"http_method": "get", "operation": "get", "ids": ["id"], "path": "countries/<id>.json"}, {"http_method": "post", "operation": "post", "ids": [], "path": "countries.json"}, {"http_method": "put", "operation": "put", "ids": ["id"], "path": "countries/<id>.json"} ]; protected static resourceNames: ResourceNames[] = [ { "singular": "country", "plural": "countries" } ]; public static async find( { session, id, fields = null }: FindArgs ): Promise<Country | null> { const result = await this.baseFind<Country>({ session: session, urlIds: {"id": id}, params: {"fields": fields}, }); return result.data ? result.data[0] : null; } public static async delete( { session, id }: DeleteArgs ): Promise<unknown> { const response = await this.request<Country>({ http_method: "delete", operation: "delete", session: session, urlIds: {"id": id}, params: {}, }); return response ? response.body : null; } public static async all( { session, since_id = null, fields = null, ...otherArgs }: AllArgs ): Promise<FindAllResponse<Country>> { const response = await this.baseFind<Country>({ session: session, urlIds: {}, params: {"since_id": since_id, "fields": fields, ...otherArgs}, }); return response; } public static async count( { session, ...otherArgs }: CountArgs ): Promise<unknown> { const response = await this.request<Country>({ http_method: "get", operation: "count", session: session, urlIds: {}, params: {...otherArgs}, body: {}, entity: null, }); return response ? response.body : null; } public code: string | null; public id: string | null; public name: string | null; public provinces: Province[] | null | {[key: string]: any}; public tax: number | null; }