@delopay/sdk 0.507.0 → 0.509.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/resources/shopify.ts"],"sourcesContent":["import type {\n ShopifyCollectionsQuery,\n ShopifyCollectionsResponse,\n ShopifyConnectRequest,\n ShopifyConnectResponse,\n ShopifyConnection,\n ShopifyConnectionList,\n ShopifyConnectionResponse,\n ShopifyPaymentModeUpdate,\n ShopifySettingsUpdate,\n ShopifyStoreCurrencies,\n ShopifySyncEvent,\n ShopifySyncEventsQuery,\n ShopifySyncEventsResponse,\n ShopifyTakeoverRules,\n ShopifyTakeoverRulesUpdate,\n ShopifyTestLink,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * A shop's link to the merchant's Shopify store: the merchant creates an app\n * in their own Shopify account, saves its keys here, approves it in Shopify,\n * and the storefront script sends the store's buyers to this shop's hosted\n * checkout. Every route names the shop by its profile id.\n *\n * Reading the connections, the sync log and its retry, the takeover rules,\n * the store's currencies and its collections, switching the payment mode and\n * changing the takeover rules take an API key or a dashboard session; a\n * session needs the shop's Read permission to read and its Write to retry,\n * switch or change the rules. Connecting, changing the settings and disconnecting take\n * a signed-in dashboard session only, never an API key, with the shop's Write\n * permission. A key or role pinned to another shop, or a checkout template's\n * profile, is refused as unknown (404). No answer carries the app's client\n * secret or the store's access token.\n */\nexport class Shopify {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * The shop's connection, if any, with the storefront's last reports, and\n * what the merchant's app must list (redirect URL, access scopes). Takes an\n * API key or a dashboard session with the shop's Read permission; a server\n * that predates API-key access refuses a key with 401. Read-only: never\n * returns a secret or a token.\n *\n * `GET /shopify/connections/{profileId}`\n */\n async retrieveConnection(\n profileId: string,\n options?: RequestExtras,\n ): Promise<ShopifyConnectionResponse> {\n return this.request('GET', `/shopify/connections/${encodeURIComponent(profileId)}`, options);\n }\n\n /**\n * The caller's stores with their payment mode: one per shop at most, and\n * only its own shop's for a shop-bound key or a shop-scoped role. Never\n * returns a secret or a token.\n *\n * `GET /shopify/connections`\n */\n async listConnections(options?: RequestExtras): Promise<ShopifyConnectionList> {\n return this.request('GET', '/shopify/connections', options);\n }\n\n /**\n * Switch the store between live and test payments. To `test`,\n * `confirm_shop_domain` must be the store's address exactly as the\n * connection shows it, and a payment provider of the shop must be able to\n * take a test payment (`test_payments_available`; 422 otherwise). In test,\n * storefront checkouts started from then on make test payments, and their\n * Shopify orders are tagged `<brand> TEST` (such as `DeloPay TEST`) and\n * must not be fulfilled. That holds only once the whole deployment serves\n * test mode (every API server, the storefront script and the order sync):\n * a deployment still mid-rollout can make a live payment or an untagged\n * order, so switch only once the deployment has finished rolling it out.\n * Back to `live` needs no typed address. Asking for the mode the store is\n * already in changes nothing. A switch made by someone else meanwhile is\n * refused with 412. A storefront checkout already started keeps the mode it\n * began in; the storefront shows the change within about a minute.\n *\n * `POST /shopify/connections/{profileId}/payment_mode`\n */\n async updatePaymentMode(\n profileId: string,\n params: ShopifyPaymentModeUpdate,\n options?: RequestExtras,\n ): Promise<ShopifyConnection> {\n return this.request(\n 'POST',\n `/shopify/connections/${encodeURIComponent(profileId)}/payment_mode`,\n { ...options, body: params },\n );\n }\n\n /**\n * A one-time link to the store that puts the browser opening it into test\n * payments for `test_duration_secs`, while every other buyer of the store\n * keeps paying live. That browser's payments are test payments with the\n * shop's test credentials, and their Shopify orders are tagged\n * `<brand> TEST` (such as `DeloPay TEST`) and must not be fulfilled. The\n * link works once, on this store only, until `link_expires_at`. Takes a\n * signed-in dashboard session with the shop's Write permission, never an\n * API key: the link is for the person's own browser, and every link made is\n * recorded with who made it and when. Refused when the store does not send\n * its buyers to this checkout or is in test already (412), and when no\n * payment provider of the shop can take a test payment\n * (`test_payments_available` is `false`; 422).\n *\n * The link only takes effect in a browser whose storefront loads a loader\n * release that supports test links, `0.18.0` or newer (the connection's\n * `loader_release` and `storefront.loader_version` say which release the\n * store is pinned to and last reported). An older release ignores the link,\n * and that browser's checkouts stay live. Making the link, or opening it,\n * proves nothing: place a test order only once the storefront shows that\n * the browser is in test mode.\n *\n * `POST /shopify/connections/{profileId}/test_link`\n */\n async createTestLink(profileId: string, options?: RequestExtras): Promise<ShopifyTestLink> {\n return this.request(\n 'POST',\n `/shopify/connections/${encodeURIComponent(profileId)}/test_link`,\n options,\n );\n }\n\n /**\n * Save the app's keys and get the Shopify page the merchant approves the app\n * on. Refused while the shop is connected (412), except to approve again in\n * place: when the connection's `authorization_expired` is `true`, saving the\n * same store's keys for the same app (same `shop_domain` and `client_id`)\n * starts a new approval while the store stays connected with its settings\n * and script. Saving the keys renews nothing by itself: the merchant must\n * open the returned `authorize_url` and approve the app again, so neither a\n * successful call nor the `connected` status proves the approval is done;\n * `authorization_expired` turns `false` once it is. Refused when the store\n * is connected to another shop (409).\n *\n * `PUT /shopify/connections/{profileId}`\n */\n async connect(\n profileId: string,\n params: ShopifyConnectRequest,\n options?: RequestExtras,\n ): Promise<ShopifyConnectResponse> {\n return this.request('PUT', `/shopify/connections/${encodeURIComponent(profileId)}`, {\n ...options,\n body: params,\n });\n }\n\n /**\n * Change the storefront settings: the takeover switch, the mode, the\n * appearance, the accepted terms. Switching the takeover on needs an\n * approved connection, and in `skip_checkout` mode the accepted terms\n * (412 otherwise).\n *\n * `PATCH /shopify/connections/{profileId}`\n */\n async updateSettings(\n profileId: string,\n params: ShopifySettingsUpdate,\n options?: RequestExtras,\n ): Promise<ShopifyConnection> {\n return this.request('PATCH', `/shopify/connections/${encodeURIComponent(profileId)}`, {\n ...options,\n body: params,\n });\n }\n\n /**\n * Disconnect the store. Buyers go back to Shopify checkout at once, and the\n * stored keys are wiped.\n *\n * `DELETE /shopify/connections/{profileId}`\n */\n async disconnect(profileId: string, options?: RequestExtras): Promise<void> {\n return this.request('DELETE', `/shopify/connections/${encodeURIComponent(profileId)}`, options);\n }\n\n /**\n * The shop's recent syncs with its store, newest first: the order of each\n * paid storefront payment, refunds in both directions, dispute flags and\n * webhook registrations. A `held` or `failed` entry was told to the\n * merchant; a `pending` one with a `reason` is retrying by itself. For the\n * next page, pass the answer's `next_cursor` as `cursor` with the same\n * filters; it is set on every full page and absent on a short one. Never\n * page by the oldest `created_at` as `before`: that skips entries sharing\n * its time.\n *\n * `GET /shopify/connections/{profileId}/sync_events`\n */\n async listSyncEvents(\n profileId: string,\n query?: ShopifySyncEventsQuery,\n options?: RequestExtras,\n ): Promise<ShopifySyncEventsResponse> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/sync_events`,\n {\n ...options,\n query: { ...query },\n },\n );\n }\n\n /**\n * Run a failed, held or waiting sync again within a minute, as a first\n * attempt would: a held order whose total still differs from what was paid\n * is held again. Never makes a second order or a second refund. An entry\n * that cannot be retried answers 404.\n *\n * `POST /shopify/connections/{profileId}/sync_events/{eventId}/retry`\n */\n async retrySyncEvent(\n profileId: string,\n eventId: string,\n options?: RequestExtras,\n ): Promise<ShopifySyncEvent> {\n return this.request(\n 'POST',\n `/shopify/connections/${encodeURIComponent(profileId)}/sync_events/${encodeURIComponent(eventId)}/retry`,\n options,\n );\n }\n\n /**\n * Which of the store's carts the storefront takes over: by buyer country,\n * presentment currency, cart value, product tag and collection. With no\n * rule set every cart is taken over. A cart in a currency the shop cannot\n * take always uses Shopify checkout, whatever the rules say.\n *\n * `GET /shopify/connections/{profileId}/takeover_rules`\n */\n async retrieveTakeoverRules(\n profileId: string,\n options?: RequestExtras,\n ): Promise<ShopifyTakeoverRules> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/takeover_rules`,\n options,\n );\n }\n\n /**\n * Replace the store's takeover rules; `{}` removes them all. Each list keeps\n * every country, currency, tag (without case) and collection once. A\n * malformed rule is refused with 422. A change applies to the next checkout\n * a buyer starts. Returns the rules as saved.\n *\n * `PUT /shopify/connections/{profileId}/takeover_rules`\n */\n async updateTakeoverRules(\n profileId: string,\n params: ShopifyTakeoverRulesUpdate,\n options?: RequestExtras,\n ): Promise<ShopifyTakeoverRules> {\n // The API refuses unknown fields: a collection as `listCollections` answers it\n // also carries its `handle`, so only the id and title are sent.\n const body: ShopifyTakeoverRulesUpdate =\n params.excluded_collections === undefined\n ? params\n : {\n ...params,\n excluded_collections: params.excluded_collections.map(({ id, title }) => ({\n id,\n title,\n })),\n };\n return this.request(\n 'PUT',\n `/shopify/connections/${encodeURIComponent(profileId)}/takeover_rules`,\n { ...options, body },\n );\n }\n\n /**\n * The currencies the store sells in (its own and its enabled market\n * currencies, read from Shopify now) and whether the shop can take a payment\n * in each. Refused while the store is not approved yet (400, `IR_16`) and\n * when Shopify cannot be read (502).\n *\n * `GET /shopify/connections/{profileId}/currencies`\n */\n async listCurrencies(\n profileId: string,\n options?: RequestExtras,\n ): Promise<ShopifyStoreCurrencies> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/currencies`,\n options,\n );\n }\n\n /**\n * The store's collections a takeover rule can name, by title, at most 25.\n * `query` matches part of a title. Refused while the store is not approved\n * yet (400, `IR_16`) and when Shopify cannot be read (502).\n *\n * `GET /shopify/connections/{profileId}/collections`\n */\n async listCollections(\n profileId: string,\n query?: ShopifyCollectionsQuery,\n options?: RequestExtras,\n ): Promise<ShopifyCollectionsResponse> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/collections`,\n { ...options, query: { ...query } },\n );\n }\n}\n"],"mappings":";AAoCO,IAAM,UAAN,MAAc;AAAA,EACnB,YAA6B,SAAoB;AAApB;AAAA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,MAAM,mBACJ,WACA,SACoC;AACpC,WAAO,KAAK,QAAQ,OAAO,wBAAwB,mBAAmB,SAAS,CAAC,IAAI,OAAO;AAAA,EAC7F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,gBAAgB,SAAyD;AAC7E,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A,MACA,wBAAwB,mBAAmB,SAAS,CAAC;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,gBACJ,WACA,OACA,SACqC;AACrC,WAAO,KAAK;AAAA,MACV;AAAA,MACA,wBAAwB,mBAAmB,SAAS,CAAC;AAAA,MACrD,EAAE,GAAG,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE;AAAA,IACpC;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/delopay-typescript-sdk/delopay-typescript-sdk/sdk/dist/chunk-YRGIXGGW.cjs","../src/resources/shopify.ts"],"names":[],"mappings":"AAAA;ACoCO,IAAM,QAAA,EAAN,MAAc;AAAA,EACnB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,MAAM,kBAAA,CACJ,SAAA,EACA,OAAA,EACoC;AACpC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA,qBAAA,EAAwB,kBAAA,CAAmB,SAAS,CAAC,CAAA,CAAA;AAClF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS+E,EAAA;AACnB,IAAA;AAC5D,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwB8B,EAAA;AAChB,IAAA;AACV,MAAA;AACqD,MAAA;AAC1B,MAAA;AAC7B,IAAA;AACF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAauC,EAAA;AACzB,IAAA;AACV,MAAA;AACqD,MAAA;AACnB,MAAA;AACpC,IAAA;AACF,EAAA;AACF;ADvFqF;AACA;AACA;AACA","file":"/home/runner/work/delopay-typescript-sdk/delopay-typescript-sdk/sdk/dist/chunk-YRGIXGGW.cjs","sourcesContent":[null,"import type {\n ShopifyCollectionsQuery,\n ShopifyCollectionsResponse,\n ShopifyConnectRequest,\n ShopifyConnectResponse,\n ShopifyConnection,\n ShopifyConnectionList,\n ShopifyConnectionResponse,\n ShopifyPaymentModeUpdate,\n ShopifySettingsUpdate,\n ShopifyStoreCurrencies,\n ShopifySyncEvent,\n ShopifySyncEventsQuery,\n ShopifySyncEventsResponse,\n ShopifyTakeoverRules,\n ShopifyTakeoverRulesUpdate,\n ShopifyTestLink,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * A shop's link to the merchant's Shopify store: the merchant creates an app\n * in their own Shopify account, saves its keys here, approves it in Shopify,\n * and the storefront script sends the store's buyers to this shop's hosted\n * checkout. Every route names the shop by its profile id.\n *\n * Reading the connections, the sync log and its retry, the takeover rules,\n * the store's currencies and its collections, switching the payment mode and\n * changing the takeover rules take an API key or a dashboard session; a\n * session needs the shop's Read permission to read and its Write to retry,\n * switch or change the rules. Connecting, changing the settings and disconnecting take\n * a signed-in dashboard session only, never an API key, with the shop's Write\n * permission. A key or role pinned to another shop, or a checkout template's\n * profile, is refused as unknown (404). No answer carries the app's client\n * secret or the store's access token.\n */\nexport class Shopify {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * The shop's connection, if any, with the storefront's last reports, and\n * what the merchant's app must list (redirect URL, access scopes). Takes an\n * API key or a dashboard session with the shop's Read permission; a server\n * that predates API-key access refuses a key with 401. Read-only: never\n * returns a secret or a token.\n *\n * `GET /shopify/connections/{profileId}`\n */\n async retrieveConnection(\n profileId: string,\n options?: RequestExtras,\n ): Promise<ShopifyConnectionResponse> {\n return this.request('GET', `/shopify/connections/${encodeURIComponent(profileId)}`, options);\n }\n\n /**\n * The caller's stores with their payment mode: one per shop at most, and\n * only its own shop's for a shop-bound key or a shop-scoped role. Never\n * returns a secret or a token.\n *\n * `GET /shopify/connections`\n */\n async listConnections(options?: RequestExtras): Promise<ShopifyConnectionList> {\n return this.request('GET', '/shopify/connections', options);\n }\n\n /**\n * Switch the store between live and test payments. To `test`,\n * `confirm_shop_domain` must be the store's address exactly as the\n * connection shows it, and a payment provider of the shop must be able to\n * take a test payment (`test_payments_available`; 422 otherwise). In test,\n * storefront checkouts started from then on make test payments, and their\n * Shopify orders are tagged `<brand> TEST` (such as `DeloPay TEST`) and\n * must not be fulfilled. That holds only once the whole deployment serves\n * test mode (every API server, the storefront script and the order sync):\n * a deployment still mid-rollout can make a live payment or an untagged\n * order, so switch only once the deployment has finished rolling it out.\n * Back to `live` needs no typed address. Asking for the mode the store is\n * already in changes nothing. A switch made by someone else meanwhile is\n * refused with 412. A storefront checkout already started keeps the mode it\n * began in; the storefront shows the change within about a minute.\n *\n * `POST /shopify/connections/{profileId}/payment_mode`\n */\n async updatePaymentMode(\n profileId: string,\n params: ShopifyPaymentModeUpdate,\n options?: RequestExtras,\n ): Promise<ShopifyConnection> {\n return this.request(\n 'POST',\n `/shopify/connections/${encodeURIComponent(profileId)}/payment_mode`,\n { ...options, body: params },\n );\n }\n\n /**\n * A one-time link to the store that puts the browser opening it into test\n * payments for `test_duration_secs`, while every other buyer of the store\n * keeps paying live. That browser's payments are test payments with the\n * shop's test credentials, and their Shopify orders are tagged\n * `<brand> TEST` (such as `DeloPay TEST`) and must not be fulfilled. The\n * link works once, on this store only, until `link_expires_at`. Takes a\n * signed-in dashboard session with the shop's Write permission, never an\n * API key: the link is for the person's own browser, and every link made is\n * recorded with who made it and when. Refused when the store does not send\n * its buyers to this checkout or is in test already (412), and when no\n * payment provider of the shop can take a test payment\n * (`test_payments_available` is `false`; 422).\n *\n * The link only takes effect in a browser whose storefront loads a loader\n * release that supports test links, `0.18.0` or newer (the connection's\n * `loader_release` and `storefront.loader_version` say which release the\n * store is pinned to and last reported). An older release ignores the link,\n * and that browser's checkouts stay live. Making the link, or opening it,\n * proves nothing: place a test order only once the storefront shows that\n * the browser is in test mode.\n *\n * `POST /shopify/connections/{profileId}/test_link`\n */\n async createTestLink(profileId: string, options?: RequestExtras): Promise<ShopifyTestLink> {\n return this.request(\n 'POST',\n `/shopify/connections/${encodeURIComponent(profileId)}/test_link`,\n options,\n );\n }\n\n /**\n * Save the app's keys and get the Shopify page the merchant approves the app\n * on. Refused while the shop is connected (412), except to approve again in\n * place: when the connection's `authorization_expired` is `true`, saving the\n * same store's keys for the same app (same `shop_domain` and `client_id`)\n * starts a new approval while the store stays connected with its settings\n * and script. Saving the keys renews nothing by itself: the merchant must\n * open the returned `authorize_url` and approve the app again, so neither a\n * successful call nor the `connected` status proves the approval is done;\n * `authorization_expired` turns `false` once it is. Refused when the store\n * is connected to another shop (409).\n *\n * `PUT /shopify/connections/{profileId}`\n */\n async connect(\n profileId: string,\n params: ShopifyConnectRequest,\n options?: RequestExtras,\n ): Promise<ShopifyConnectResponse> {\n return this.request('PUT', `/shopify/connections/${encodeURIComponent(profileId)}`, {\n ...options,\n body: params,\n });\n }\n\n /**\n * Change the storefront settings: the takeover switch, the mode, the\n * appearance, the accepted terms. Switching the takeover on needs an\n * approved connection, and in `skip_checkout` mode the accepted terms\n * (412 otherwise).\n *\n * `PATCH /shopify/connections/{profileId}`\n */\n async updateSettings(\n profileId: string,\n params: ShopifySettingsUpdate,\n options?: RequestExtras,\n ): Promise<ShopifyConnection> {\n return this.request('PATCH', `/shopify/connections/${encodeURIComponent(profileId)}`, {\n ...options,\n body: params,\n });\n }\n\n /**\n * Disconnect the store. Buyers go back to Shopify checkout at once, and the\n * stored keys are wiped.\n *\n * `DELETE /shopify/connections/{profileId}`\n */\n async disconnect(profileId: string, options?: RequestExtras): Promise<void> {\n return this.request('DELETE', `/shopify/connections/${encodeURIComponent(profileId)}`, options);\n }\n\n /**\n * The shop's recent syncs with its store, newest first: the order of each\n * paid storefront payment, refunds in both directions, dispute flags and\n * webhook registrations. A `held` or `failed` entry was told to the\n * merchant; a `pending` one with a `reason` is retrying by itself. For the\n * next page, pass the answer's `next_cursor` as `cursor` with the same\n * filters; it is set on every full page and absent on a short one. Never\n * page by the oldest `created_at` as `before`: that skips entries sharing\n * its time.\n *\n * `GET /shopify/connections/{profileId}/sync_events`\n */\n async listSyncEvents(\n profileId: string,\n query?: ShopifySyncEventsQuery,\n options?: RequestExtras,\n ): Promise<ShopifySyncEventsResponse> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/sync_events`,\n {\n ...options,\n query: { ...query },\n },\n );\n }\n\n /**\n * Run a failed, held or waiting sync again within a minute, as a first\n * attempt would: a held order whose total still differs from what was paid\n * is held again. Never makes a second order or a second refund. An entry\n * that cannot be retried answers 404.\n *\n * `POST /shopify/connections/{profileId}/sync_events/{eventId}/retry`\n */\n async retrySyncEvent(\n profileId: string,\n eventId: string,\n options?: RequestExtras,\n ): Promise<ShopifySyncEvent> {\n return this.request(\n 'POST',\n `/shopify/connections/${encodeURIComponent(profileId)}/sync_events/${encodeURIComponent(eventId)}/retry`,\n options,\n );\n }\n\n /**\n * Which of the store's carts the storefront takes over: by buyer country,\n * presentment currency, cart value, product tag and collection. With no\n * rule set every cart is taken over. A cart in a currency the shop cannot\n * take always uses Shopify checkout, whatever the rules say.\n *\n * `GET /shopify/connections/{profileId}/takeover_rules`\n */\n async retrieveTakeoverRules(\n profileId: string,\n options?: RequestExtras,\n ): Promise<ShopifyTakeoverRules> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/takeover_rules`,\n options,\n );\n }\n\n /**\n * Replace the store's takeover rules; `{}` removes them all. Each list keeps\n * every country, currency, tag (without case) and collection once. A\n * malformed rule is refused with 422. A change applies to the next checkout\n * a buyer starts. Returns the rules as saved.\n *\n * `PUT /shopify/connections/{profileId}/takeover_rules`\n */\n async updateTakeoverRules(\n profileId: string,\n params: ShopifyTakeoverRulesUpdate,\n options?: RequestExtras,\n ): Promise<ShopifyTakeoverRules> {\n // The API refuses unknown fields: a collection as `listCollections` answers it\n // also carries its `handle`, so only the id and title are sent.\n const body: ShopifyTakeoverRulesUpdate =\n params.excluded_collections === undefined\n ? params\n : {\n ...params,\n excluded_collections: params.excluded_collections.map(({ id, title }) => ({\n id,\n title,\n })),\n };\n return this.request(\n 'PUT',\n `/shopify/connections/${encodeURIComponent(profileId)}/takeover_rules`,\n { ...options, body },\n );\n }\n\n /**\n * The currencies the store sells in (its own and its enabled market\n * currencies, read from Shopify now) and whether the shop can take a payment\n * in each. Refused while the store is not approved yet (400, `IR_16`) and\n * when Shopify cannot be read (502).\n *\n * `GET /shopify/connections/{profileId}/currencies`\n */\n async listCurrencies(\n profileId: string,\n options?: RequestExtras,\n ): Promise<ShopifyStoreCurrencies> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/currencies`,\n options,\n );\n }\n\n /**\n * The store's collections a takeover rule can name, by title, at most 25.\n * `query` matches part of a title. Refused while the store is not approved\n * yet (400, `IR_16`) and when Shopify cannot be read (502).\n *\n * `GET /shopify/connections/{profileId}/collections`\n */\n async listCollections(\n profileId: string,\n query?: ShopifyCollectionsQuery,\n options?: RequestExtras,\n ): Promise<ShopifyCollectionsResponse> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/collections`,\n { ...options, query: { ...query } },\n );\n }\n}\n"]}