Skip to content

Commit

Permalink
fix: Locale that is used for 'accept-language' and 'content-language'…
Browse files Browse the repository at this point in the history
… was mixed with LocaleEnum that should be used in Inventory API

 * this should fix the problem with issue_refund see https://community.ebay.com/t5/Post-Order-APIs-Return/error-when-posting-to-issue-refund-with-returnid/m-p/34000648#M14
  • Loading branch information
dantio committed Sep 28, 2023
1 parent 98b0aeb commit dd4b71d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const eBay = new eBayApi({

marketplaceId: eBayApi.MarketplaceId.EBAY_US, // default. required for RESTful APIs
acceptLanguage: eBayApi.Locale.en_US, // default
contentLanguage: eBayApi.ContentLanguage.en_US, // default.
contentLanguage: eBayApi.Locale.en_US, // default.

// optional parameters, should be omitted if not used
devId: '-- devId --', // required for traditional Trading API
Expand Down Expand Up @@ -166,7 +166,7 @@ The first (required) parameter in eBayApi instance takes an object with followin
| marketplaceId<br><i>RESTful</i> | Required<br><pre>Default: `MarketplaceId.EBAY_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#marketpl) REST HTTP Header. X-EBAY-C-MARKETPLACE-ID identifies the user's business context and is specified using a marketplace ID value. Note that this header does not indicate a language preference or consumer location. |
| scope<br><i>RESTful</i> | Conditionally<bre><pre>Default:<br>`['https://api.ebay.com/oauth/api_scope']` </pre> | The scopes assigned to your application allow access to different API resources and functionality. |
| endUserCtx<br><i>RESTful</i> | Conditionally recommended<br><i>RESTful</i> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers) X-EBAY\_C\_ENDUSERCTX provides various types of information associated with the request. |
| contentLanguage<br><i>RESTful</i> | Conditionally required<br><pre>Default: `ContentLanguage.en_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers)Content-Language indicates the locale preferred by the client for the response. |
| contentLanguage<br><i>RESTful</i> | Conditionally required<br><pre>Default: `Locale.en_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers)Content-Language indicates the locale preferred by the client for the response. |
| acceptLanguage<br><i>RESTful</i> | Optional<pre>Default: `Locale.en_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers) Accept-Language indicates the natural language the client prefers for the response. This specifies the language the client wants to use when the field values provided in the request body are displayed to consumers. |

## Load config from environment
Expand Down
56 changes: 33 additions & 23 deletions src/enums/restfulEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,33 @@ export enum CurrencyCode {
ZWL = 'ZWL'
}

export enum Locale {
de_AT = 'de-AT',
de_CH = 'de-CH',
de_DE = 'de-DE',
en_AU = 'en-AU',
en_CA = 'en-CA',
en_GB = 'en-GB',
en_IE = 'en-IE',
en_PH = 'en-PH',
en_US = 'en-US',
es_ES = 'es-ES',
fr_BE = 'fr-BE',
fr_CA = 'fr-CA',
fr_FR = 'fr-FR',
it_IT = 'it-IT',
nl_BE = 'nl-BE',
nl_NL = 'nl-NL',
pl_PL = 'pl-PL',
th_TH = 'th-TH',
zh_HK = 'zh-HK',
zh_TW = 'zh-TW',
}

export {
Locale as ContentLanguage
}

export enum Condition {
NEW = 'NEW',
LIKE_NEW = 'LIKE_NEW',
Expand All @@ -802,7 +829,12 @@ export enum Condition {
FOR_PARTS_OR_NOT_WORKING = 'FOR_PARTS_OR_NOT_WORKING'
}

export enum Locale {
/**
* Inventory API:
* This enumeration type contains the different locales that can be used.
* The locale value indicates the language that is used to express the inventory item details.
*/
export enum LocaleEnum {
en_US = 'en_US',
en_CA = 'en_CA',
fr_CA = 'fr_CA',
Expand Down Expand Up @@ -830,28 +862,6 @@ export enum Locale {
en_MY = 'en_MY'
}

export enum ContentLanguage {
de_AT = 'de-AT',
de_CH = 'de-CH',
de_DE = 'de-DE',
en_AU = 'en-AU',
en_CA = 'en-CA',
en_GB = 'en-GB',
en_IE = 'en-IE',
en_PH = 'en-PH',
en_US = 'en-US',
es_ES = 'es-ES',
fr_BE = 'fr-BE',
fr_CA = 'fr-CA',
fr_FR = 'fr-FR',
it_IT = 'it-IT',
nl_BE = 'nl-BE',
nl_NL = 'nl-NL',
pl_PL = 'pl-PL',
th_TH = 'th-TH',
zh_HK = 'zh-HK',
zh_TW = 'zh-TW',
}

export enum Marketplace {
EBAY_US = 'EBAY_US',
Expand Down
4 changes: 2 additions & 2 deletions src/types/apiTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AxiosRequestConfig} from 'axios';
import {ContentLanguage, Locale, MarketplaceId, SiteId} from '../enums/index.js';
import {Locale, MarketplaceId, SiteId} from '../enums/index.js';

export type Scope = string[];

Expand All @@ -12,7 +12,7 @@ export type Keyset = {
export type RestConfig = {
marketplaceId?: MarketplaceId | `${MarketplaceId}`,
endUserCtx?: string,
contentLanguage?: ContentLanguage | `${ContentLanguage}`
contentLanguage?: Locale | `${Locale}`
acceptLanguage?: Locale | `${Locale}`
}

Expand Down

0 comments on commit dd4b71d

Please sign in to comment.