Skip to content

Commit

Permalink
Merge pull request #177 from Borales/order-create-embed
Browse files Browse the repository at this point in the history
Adding `embed` param to Orders.create method.
  • Loading branch information
Pimm authored Oct 28, 2020
2 parents 01915dc + 0f005c2 commit df9519c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/resources/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class Resource<R, T extends R> {
this.network = {
post: async <S extends T | true = T>(url: string, data: any, query: Record<string, any> = {}): Promise<S> => {
try {
var response: AxiosResponse = await httpClient.post(url, data);
var response: AxiosResponse = await httpClient.post(`${url}${stringifyQuery(query)}`, data);
} catch (error) {
if (error.response != undefined) {
throw ApiError.createFromResponse(error.response);
Expand Down
4 changes: 3 additions & 1 deletion src/resources/orders/OrdersResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export default class OrdersResource extends Resource<OrderData, Order> {
public create(parameters: CreateParameters): void;
public create(parameters: CreateParameters) {
if (renege(this, this.create, ...arguments)) return;
return this.network.post(this.getResourceUrl(), parameters);
const { embed, ...data } = parameters;
const query = embed != undefined ? { embed } : undefined;
return this.network.post(this.getResourceUrl(), data, query);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/resources/orders/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type CreateParameters = Pick<OrderData, 'amount' | 'orderNumber' | 'billi
* only.
*/
shopperCountryMustMatchBillingCountry?: boolean;
embed?: OrderEmbed.payments[];
profileId?: string;
testmode?: boolean;
};
Expand Down

0 comments on commit df9519c

Please sign in to comment.