From afbc960a3c41e6d08e1550f0c7021c4cbc9297c0 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 2 Apr 2024 09:15:08 +0200 Subject: [PATCH 1/5] feat: add Shop.current method --- packages/shopify-api/rest/admin/2024-01/shop.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/shopify-api/rest/admin/2024-01/shop.ts b/packages/shopify-api/rest/admin/2024-01/shop.ts index 2efd16445..3dd3ea1a4 100644 --- a/packages/shopify-api/rest/admin/2024-01/shop.ts +++ b/packages/shopify-api/rest/admin/2024-01/shop.ts @@ -28,6 +28,23 @@ export class Shop extends Base { } ]; + public static async current( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const result = await this.baseFind({ + session: session, + urlIds: {}, + params: {"fields": fields, ...otherArgs}, + }); + + return result.data ? result.data[0] : null; + } + + public static async all( { session, From 8e151f5acfc6fb47ec7af20b94470d76be743b50 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 2 Apr 2024 19:01:34 +0200 Subject: [PATCH 2/5] feat: add Shop.current method to other versions --- packages/shopify-api/rest/admin/2022-10/shop.ts | 16 ++++++++++++++++ packages/shopify-api/rest/admin/2023-01/shop.ts | 16 ++++++++++++++++ packages/shopify-api/rest/admin/2023-04/shop.ts | 16 ++++++++++++++++ packages/shopify-api/rest/admin/2023-07/shop.ts | 16 ++++++++++++++++ packages/shopify-api/rest/admin/2023-10/shop.ts | 16 ++++++++++++++++ 5 files changed, 80 insertions(+) diff --git a/packages/shopify-api/rest/admin/2022-10/shop.ts b/packages/shopify-api/rest/admin/2022-10/shop.ts index 6905876f4..0eb99ad29 100644 --- a/packages/shopify-api/rest/admin/2022-10/shop.ts +++ b/packages/shopify-api/rest/admin/2022-10/shop.ts @@ -28,6 +28,22 @@ export class Shop extends Base { } ]; + public static async current( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const result = await this.baseFind({ + session: session, + urlIds: {}, + params: {"fields": fields, ...otherArgs}, + }); + + return result.data ? result.data[0] : null; + } + public static async all( { session, diff --git a/packages/shopify-api/rest/admin/2023-01/shop.ts b/packages/shopify-api/rest/admin/2023-01/shop.ts index 4f7e59ee4..74f514a20 100644 --- a/packages/shopify-api/rest/admin/2023-01/shop.ts +++ b/packages/shopify-api/rest/admin/2023-01/shop.ts @@ -28,6 +28,22 @@ export class Shop extends Base { } ]; + public static async current( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const result = await this.baseFind({ + session: session, + urlIds: {}, + params: {"fields": fields, ...otherArgs}, + }); + + return result.data ? result.data[0] : null; + } + public static async all( { session, diff --git a/packages/shopify-api/rest/admin/2023-04/shop.ts b/packages/shopify-api/rest/admin/2023-04/shop.ts index 4a651196d..832627fc0 100644 --- a/packages/shopify-api/rest/admin/2023-04/shop.ts +++ b/packages/shopify-api/rest/admin/2023-04/shop.ts @@ -28,6 +28,22 @@ export class Shop extends Base { } ]; + public static async current( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const result = await this.baseFind({ + session: session, + urlIds: {}, + params: {"fields": fields, ...otherArgs}, + }); + + return result.data ? result.data[0] : null; + } + public static async all( { session, diff --git a/packages/shopify-api/rest/admin/2023-07/shop.ts b/packages/shopify-api/rest/admin/2023-07/shop.ts index 7d9104f1f..832fe7be6 100644 --- a/packages/shopify-api/rest/admin/2023-07/shop.ts +++ b/packages/shopify-api/rest/admin/2023-07/shop.ts @@ -28,6 +28,22 @@ export class Shop extends Base { } ]; + public static async current( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const result = await this.baseFind({ + session: session, + urlIds: {}, + params: {"fields": fields, ...otherArgs}, + }); + + return result.data ? result.data[0] : null; + } + public static async all( { session, diff --git a/packages/shopify-api/rest/admin/2023-10/shop.ts b/packages/shopify-api/rest/admin/2023-10/shop.ts index 615b89ddc..42dc70dd6 100644 --- a/packages/shopify-api/rest/admin/2023-10/shop.ts +++ b/packages/shopify-api/rest/admin/2023-10/shop.ts @@ -28,6 +28,22 @@ export class Shop extends Base { } ]; + public static async current( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const result = await this.baseFind({ + session: session, + urlIds: {}, + params: {"fields": fields, ...otherArgs}, + }); + + return result.data ? result.data[0] : null; + } + public static async all( { session, From f72df2476e7a4d979f9eae4f1800647d36200fdf Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 2 Apr 2024 19:15:06 +0200 Subject: [PATCH 3/5] chore: add tests for Shop.current method --- .../rest/admin/__tests__/2022-10/shop.test.ts | 43 +++++++++++++++++++ .../rest/admin/__tests__/2023-01/shop.test.ts | 43 +++++++++++++++++++ .../rest/admin/__tests__/2023-04/shop.test.ts | 43 +++++++++++++++++++ .../rest/admin/__tests__/2023-07/shop.test.ts | 43 +++++++++++++++++++ .../rest/admin/__tests__/2023-10/shop.test.ts | 43 +++++++++++++++++++ .../rest/admin/__tests__/2024-01/shop.test.ts | 43 +++++++++++++++++++ 6 files changed, 258 insertions(+) diff --git a/packages/shopify-api/rest/admin/__tests__/2022-10/shop.test.ts b/packages/shopify-api/rest/admin/__tests__/2022-10/shop.test.ts index 2c539dfed..f81555362 100644 --- a/packages/shopify-api/rest/admin/__tests__/2022-10/shop.test.ts +++ b/packages/shopify-api/rest/admin/__tests__/2022-10/shop.test.ts @@ -63,5 +63,48 @@ describe('Shop resource', () => { data: undefined }).toMatchMadeHttpRequest(); }); + + it('test_3', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.October22, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"id": 548380009, "name": "John Smith Test Store", "email": "j.smith@example.com", "domain": "shop.apple.com", "province": "California", "country": "US", "address1": "1 Infinite Loop", "zip": "95014", "city": "Cupertino", "source": null, "phone": "1231231234", "latitude": 45.45, "longitude": -75.43, "primary_locale": "en", "address2": "Suite 100", "created_at": "2007-12-31T19:00:00-05:00", "updated_at": "2023-10-03T13:18:39-04:00", "country_code": "US", "country_name": "United States", "currency": "USD", "customer_email": "customers@apple.com", "timezone": "(GMT-05:00) Eastern Time (US & Canada)", "iana_timezone": "America/New_York", "shop_owner": "John Smith", "money_format": "${{amount}}", "money_with_currency_format": "${{amount}} USD", "weight_unit": "lb", "province_code": "CA", "taxes_included": null, "auto_configure_tax_inclusivity": null, "tax_shipping": null, "county_taxes": true, "plan_display_name": "Shopify Plus", "plan_name": "enterprise", "has_discounts": true, "has_gift_cards": true, "myshopify_domain": "jsmith.myshopify.com", "google_apps_domain": null, "google_apps_login_enabled": null, "money_in_emails_format": "${{amount}}", "money_with_currency_in_emails_format": "${{amount}} USD", "eligible_for_payments": true, "requires_extra_payments_agreement": false, "password_enabled": false, "has_storefront": true, "finances": true, "primary_location_id": 655441491, "checkout_api_supported": true, "multi_location_enabled": true, "setup_required": false, "pre_launch_enabled": false, "enabled_presentment_currencies": ["USD"], "transactional_sms_disabled": false, "marketing_sms_consent_enabled_at_checkout": false}})); + + await shopify.rest.Shop.current({ + session: session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-10/shop.json', + query: '', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.October22, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"province": "California", "country": "US", "address1": "1 Infinite Loop", "city": "Cupertino", "address2": "Suite 100"}})); + + await shopify.rest.Shop.current({ + session: session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-10/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); }); diff --git a/packages/shopify-api/rest/admin/__tests__/2023-01/shop.test.ts b/packages/shopify-api/rest/admin/__tests__/2023-01/shop.test.ts index aa3019108..2d593f55e 100644 --- a/packages/shopify-api/rest/admin/__tests__/2023-01/shop.test.ts +++ b/packages/shopify-api/rest/admin/__tests__/2023-01/shop.test.ts @@ -64,4 +64,47 @@ describe('Shop resource', () => { }).toMatchMadeHttpRequest(); }); + it('test_3', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.January23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"id": 548380009, "name": "John Smith Test Store", "email": "j.smith@example.com", "domain": "shop.apple.com", "province": "California", "country": "US", "address1": "1 Infinite Loop", "zip": "95014", "city": "Cupertino", "source": null, "phone": "1231231234", "latitude": 45.45, "longitude": -75.43, "primary_locale": "en", "address2": "Suite 100", "created_at": "2007-12-31T19:00:00-05:00", "updated_at": "2024-01-02T09:00:54-05:00", "country_code": "US", "country_name": "United States", "currency": "USD", "customer_email": "customers@apple.com", "timezone": "(GMT-05:00) Eastern Time (US & Canada)", "iana_timezone": "America/New_York", "shop_owner": "John Smith", "money_format": "${{amount}}", "money_with_currency_format": "${{amount}} USD", "weight_unit": "lb", "province_code": "CA", "taxes_included": null, "auto_configure_tax_inclusivity": null, "tax_shipping": null, "county_taxes": true, "plan_display_name": "Shopify Plus", "plan_name": "enterprise", "has_discounts": true, "has_gift_cards": true, "myshopify_domain": "jsmith.myshopify.com", "google_apps_domain": null, "google_apps_login_enabled": null, "money_in_emails_format": "${{amount}}", "money_with_currency_in_emails_format": "${{amount}} USD", "eligible_for_payments": true, "requires_extra_payments_agreement": false, "password_enabled": false, "has_storefront": true, "finances": true, "primary_location_id": 655441491, "checkout_api_supported": true, "multi_location_enabled": true, "setup_required": false, "pre_launch_enabled": false, "enabled_presentment_currencies": ["USD"], "transactional_sms_disabled": false, "marketing_sms_consent_enabled_at_checkout": false}})); + + await shopify.rest.Shop.current({ + session: session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-01/shop.json', + query: '', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.January23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"province": "California", "country": "US", "address1": "1 Infinite Loop", "city": "Cupertino", "address2": "Suite 100"}})); + + await shopify.rest.Shop.current({ + session: session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-01/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + }); diff --git a/packages/shopify-api/rest/admin/__tests__/2023-04/shop.test.ts b/packages/shopify-api/rest/admin/__tests__/2023-04/shop.test.ts index 70c86c961..fee519971 100644 --- a/packages/shopify-api/rest/admin/__tests__/2023-04/shop.test.ts +++ b/packages/shopify-api/rest/admin/__tests__/2023-04/shop.test.ts @@ -64,4 +64,47 @@ describe('Shop resource', () => { }).toMatchMadeHttpRequest(); }); + it('test_3', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.April23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"id": 548380009, "name": "John Smith Test Store", "email": "j.smith@example.com", "domain": "shop.apple.com", "province": "California", "country": "US", "address1": "1 Infinite Loop", "zip": "95014", "city": "Cupertino", "source": null, "phone": "1231231234", "latitude": 45.45, "longitude": -75.43, "primary_locale": "en", "address2": "Suite 100", "created_at": "2007-12-31T19:00:00-05:00", "updated_at": "2024-01-02T09:00:54-05:00", "country_code": "US", "country_name": "United States", "currency": "USD", "customer_email": "customers@apple.com", "timezone": "(GMT-05:00) Eastern Time (US & Canada)", "iana_timezone": "America/New_York", "shop_owner": "John Smith", "money_format": "${{amount}}", "money_with_currency_format": "${{amount}} USD", "weight_unit": "lb", "province_code": "CA", "taxes_included": null, "auto_configure_tax_inclusivity": null, "tax_shipping": null, "county_taxes": true, "plan_display_name": "Shopify Plus", "plan_name": "enterprise", "has_discounts": true, "has_gift_cards": true, "myshopify_domain": "jsmith.myshopify.com", "google_apps_domain": null, "google_apps_login_enabled": null, "money_in_emails_format": "${{amount}}", "money_with_currency_in_emails_format": "${{amount}} USD", "eligible_for_payments": true, "requires_extra_payments_agreement": false, "password_enabled": false, "has_storefront": true, "finances": true, "primary_location_id": 655441491, "checkout_api_supported": true, "multi_location_enabled": true, "setup_required": false, "pre_launch_enabled": false, "enabled_presentment_currencies": ["USD"], "transactional_sms_disabled": false, "marketing_sms_consent_enabled_at_checkout": false}})); + + await shopify.rest.Shop.current({ + session: session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-04/shop.json', + query: '', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.April23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"province": "California", "country": "US", "address1": "1 Infinite Loop", "city": "Cupertino", "address2": "Suite 100"}})); + + await shopify.rest.Shop.current({ + session: session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-04/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + }); diff --git a/packages/shopify-api/rest/admin/__tests__/2023-07/shop.test.ts b/packages/shopify-api/rest/admin/__tests__/2023-07/shop.test.ts index 73a338950..2609c720d 100644 --- a/packages/shopify-api/rest/admin/__tests__/2023-07/shop.test.ts +++ b/packages/shopify-api/rest/admin/__tests__/2023-07/shop.test.ts @@ -64,4 +64,47 @@ describe('Shop resource', () => { }).toMatchMadeHttpRequest(); }); + it('test_3', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.July23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"id": 548380009, "name": "John Smith Test Store", "email": "j.smith@example.com", "domain": "shop.apple.com", "province": "California", "country": "US", "address1": "1 Infinite Loop", "zip": "95014", "city": "Cupertino", "source": null, "phone": "1231231234", "latitude": 45.45, "longitude": -75.43, "primary_locale": "en", "address2": "Suite 100", "created_at": "2007-12-31T19:00:00-05:00", "updated_at": "2024-01-02T09:00:54-05:00", "country_code": "US", "country_name": "United States", "currency": "USD", "customer_email": "customers@apple.com", "timezone": "(GMT-05:00) Eastern Time (US & Canada)", "iana_timezone": "America/New_York", "shop_owner": "John Smith", "money_format": "${{amount}}", "money_with_currency_format": "${{amount}} USD", "weight_unit": "lb", "province_code": "CA", "taxes_included": null, "auto_configure_tax_inclusivity": null, "tax_shipping": null, "county_taxes": true, "plan_display_name": "Shopify Plus", "plan_name": "enterprise", "has_discounts": true, "has_gift_cards": true, "myshopify_domain": "jsmith.myshopify.com", "google_apps_domain": null, "google_apps_login_enabled": null, "money_in_emails_format": "${{amount}}", "money_with_currency_in_emails_format": "${{amount}} USD", "eligible_for_payments": true, "requires_extra_payments_agreement": false, "password_enabled": false, "has_storefront": true, "finances": true, "primary_location_id": 655441491, "checkout_api_supported": true, "multi_location_enabled": true, "setup_required": false, "pre_launch_enabled": false, "enabled_presentment_currencies": ["USD"], "transactional_sms_disabled": false, "marketing_sms_consent_enabled_at_checkout": false}})); + + await shopify.rest.Shop.current({ + session: session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-07/shop.json', + query: '', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.July23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"province": "California", "country": "US", "address1": "1 Infinite Loop", "city": "Cupertino", "address2": "Suite 100"}})); + + await shopify.rest.Shop.current({ + session: session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-07/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + }); diff --git a/packages/shopify-api/rest/admin/__tests__/2023-10/shop.test.ts b/packages/shopify-api/rest/admin/__tests__/2023-10/shop.test.ts index 39717bb8e..9d4b28cb7 100644 --- a/packages/shopify-api/rest/admin/__tests__/2023-10/shop.test.ts +++ b/packages/shopify-api/rest/admin/__tests__/2023-10/shop.test.ts @@ -64,4 +64,47 @@ describe('Shop resource', () => { }).toMatchMadeHttpRequest(); }); + it('test_3', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.October23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"id": 548380009, "name": "John Smith Test Store", "email": "j.smith@example.com", "domain": "shop.apple.com", "province": "California", "country": "US", "address1": "1 Infinite Loop", "zip": "95014", "city": "Cupertino", "source": null, "phone": "1231231234", "latitude": 45.45, "longitude": -75.43, "primary_locale": "en", "address2": "Suite 100", "created_at": "2007-12-31T19:00:00-05:00", "updated_at": "2024-01-02T09:00:54-05:00", "country_code": "US", "country_name": "United States", "currency": "USD", "customer_email": "customers@apple.com", "timezone": "(GMT-05:00) Eastern Time (US & Canada)", "iana_timezone": "America/New_York", "shop_owner": "John Smith", "money_format": "${{amount}}", "money_with_currency_format": "${{amount}} USD", "weight_unit": "lb", "province_code": "CA", "taxes_included": null, "auto_configure_tax_inclusivity": null, "tax_shipping": null, "county_taxes": true, "plan_display_name": "Shopify Plus", "plan_name": "enterprise", "has_discounts": true, "has_gift_cards": true, "myshopify_domain": "jsmith.myshopify.com", "google_apps_domain": null, "google_apps_login_enabled": null, "money_in_emails_format": "${{amount}}", "money_with_currency_in_emails_format": "${{amount}} USD", "eligible_for_payments": true, "requires_extra_payments_agreement": false, "password_enabled": false, "has_storefront": true, "finances": true, "primary_location_id": 655441491, "checkout_api_supported": true, "multi_location_enabled": true, "setup_required": false, "pre_launch_enabled": false, "enabled_presentment_currencies": ["USD"], "transactional_sms_disabled": false, "marketing_sms_consent_enabled_at_checkout": false}})); + + await shopify.rest.Shop.current({ + session: session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-10/shop.json', + query: '', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.October23, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"province": "California", "country": "US", "address1": "1 Infinite Loop", "city": "Cupertino", "address2": "Suite 100"}})); + + await shopify.rest.Shop.current({ + session: session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2023-10/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + }); diff --git a/packages/shopify-api/rest/admin/__tests__/2024-01/shop.test.ts b/packages/shopify-api/rest/admin/__tests__/2024-01/shop.test.ts index 37c54fc79..b6d1b8874 100644 --- a/packages/shopify-api/rest/admin/__tests__/2024-01/shop.test.ts +++ b/packages/shopify-api/rest/admin/__tests__/2024-01/shop.test.ts @@ -64,4 +64,47 @@ describe('Shop resource', () => { }).toMatchMadeHttpRequest(); }); + it('test_3', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.January24, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"id": 548380009, "name": "John Smith Test Store", "email": "j.smith@example.com", "domain": "shop.apple.com", "province": "California", "country": "US", "address1": "1 Infinite Loop", "zip": "95014", "city": "Cupertino", "source": null, "phone": "1231231234", "latitude": 45.45, "longitude": -75.43, "primary_locale": "en", "address2": "Suite 100", "created_at": "2007-12-31T19:00:00-05:00", "updated_at": "2024-01-02T09:00:54-05:00", "country_code": "US", "country_name": "United States", "currency": "USD", "customer_email": "customers@apple.com", "timezone": "(GMT-05:00) Eastern Time (US & Canada)", "iana_timezone": "America/New_York", "shop_owner": "John Smith", "money_format": "${{amount}}", "money_with_currency_format": "${{amount}} USD", "weight_unit": "lb", "province_code": "CA", "taxes_included": null, "auto_configure_tax_inclusivity": null, "tax_shipping": null, "county_taxes": true, "plan_display_name": "Shopify Plus", "plan_name": "enterprise", "has_discounts": true, "has_gift_cards": true, "myshopify_domain": "jsmith.myshopify.com", "google_apps_domain": null, "google_apps_login_enabled": null, "money_in_emails_format": "${{amount}}", "money_with_currency_in_emails_format": "${{amount}} USD", "eligible_for_payments": true, "requires_extra_payments_agreement": false, "password_enabled": false, "has_storefront": true, "finances": true, "primary_location_id": 655441491, "checkout_api_supported": true, "multi_location_enabled": true, "setup_required": false, "pre_launch_enabled": false, "enabled_presentment_currencies": ["USD"], "transactional_sms_disabled": false, "marketing_sms_consent_enabled_at_checkout": false}})); + + await shopify.rest.Shop.current({ + session: session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2024-01/shop.json', + query: '', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + const shopify = shopifyApi( + testConfig({apiVersion: ApiVersion.January24, restResources}), + ); + + queueMockResponse(JSON.stringify({"shop": {"province": "California", "country": "US", "address1": "1 Infinite Loop", "city": "Cupertino", "address2": "Suite 100"}})); + + await shopify.rest.Shop.current({ + session: session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2024-01/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: undefined + }).toMatchMadeHttpRequest(); + }); + }); From c9dff9f1afc2ba45b47299cc36c045ac34cf0fcd Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 3 Apr 2024 07:54:21 +0200 Subject: [PATCH 4/5] chore: add changeset --- .changeset/twenty-impalas-chew.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/twenty-impalas-chew.md diff --git a/.changeset/twenty-impalas-chew.md b/.changeset/twenty-impalas-chew.md new file mode 100644 index 000000000..7232b0ae9 --- /dev/null +++ b/.changeset/twenty-impalas-chew.md @@ -0,0 +1,5 @@ +--- +"@shopify/shopify-api": major +--- + +add Shop.current method From de3bdb8fbb5c9f252a8752607dcece89ab286aee Mon Sep 17 00:00:00 2001 From: Paulo Margarido <64600052+paulomarg@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:12:03 -0400 Subject: [PATCH 5/5] Fix changeset --- .changeset/twenty-impalas-chew.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/twenty-impalas-chew.md b/.changeset/twenty-impalas-chew.md index 7232b0ae9..8f7965011 100644 --- a/.changeset/twenty-impalas-chew.md +++ b/.changeset/twenty-impalas-chew.md @@ -1,5 +1,5 @@ --- -"@shopify/shopify-api": major +"@shopify/shopify-api": minor --- -add Shop.current method +Add `Shop.current()` method to the REST resources