@@ -13,6 +13,7 @@ import {
1313 SearchForCompanyAssociationPostBody
1414} from "./types" ;
1515import Mapping from "../../mapping/mapping" ;
16+ import { addRequestIdHeader } from "../../util" ;
1617
1718/**
1819 * A service class for managing communications with the associations API.
@@ -38,7 +39,8 @@ export default class AssociationsService {
3839 companyNumber : string ,
3940 includeRemoved ?: boolean ,
4041 pageIndex ?: number ,
41- itemsPerPage ?: number
42+ itemsPerPage ?: number ,
43+ requestId ?: string
4244 ) : Promise < Resource < AssociationList | Errors > > {
4345 let queryString : string = "" ;
4446 if ( includeRemoved || pageIndex || itemsPerPage ) {
@@ -51,7 +53,8 @@ export default class AssociationsService {
5153 }
5254
5355 const url = `/associations/companies/${ companyNumber } ${ queryString } ` ;
54- const response = await this . client . httpGet ( url ) ;
56+ const headers = addRequestIdHeader ( requestId ) ;
57+ const response = await this . client . httpGet ( url , headers ) ;
5558
5659 return this . getResource ( response ) as Resource < AssociationList | Errors > ;
5760 }
@@ -73,16 +76,17 @@ export default class AssociationsService {
7376 companyNumber : string ,
7477 userEmail ?: string ,
7578 userId ?: string ,
76- associationStatus ?: AssociationStatus [ ]
79+ associationStatus ?: AssociationStatus [ ] ,
80+ requestId ?: string
7781 ) : Promise < Resource < Association | Errors > > {
7882 const url = `/associations/companies/${ companyNumber } /search` ;
7983
8084 const body : SearchForCompanyAssociationPostBody = { } ;
8185 if ( userEmail ) body . user_email = userEmail ;
8286 if ( userId ) body . user_id = userId ;
8387 if ( associationStatus ) body . status = associationStatus ;
84-
85- const response = await this . client . httpPost ( url , body ) ;
88+ const headers = addRequestIdHeader ( requestId ) ;
89+ const response = await this . client . httpPost ( url , body , headers ) ;
8690
8791 return this . getResource ( response ) as Resource < Association | Errors > ;
8892 }
@@ -99,7 +103,8 @@ export default class AssociationsService {
99103 associationStatus : AssociationStatus [ ] ,
100104 pageIndex ?: number ,
101105 itemsPerPage ?: number ,
102- companyNumber ?: string
106+ companyNumber ?: string ,
107+ requestId ?: string
103108 ) : Promise < Resource < AssociationList | Errors > > {
104109 const queryParameters : QueryParameters = {
105110 page_index : pageIndex || undefined ,
@@ -110,7 +115,8 @@ export default class AssociationsService {
110115 const queryString = this . getQueryString ( queryParameters ) ;
111116
112117 const url = `/associations${ queryString } ` ;
113- const response = await this . client . httpGet ( url ) ;
118+ const headers = addRequestIdHeader ( requestId ) ;
119+ const response = await this . client . httpGet ( url , headers ) ;
114120
115121 return this . getResource ( response ) as Resource < AssociationList | Errors > ;
116122 }
@@ -123,11 +129,13 @@ export default class AssociationsService {
123129 */
124130 public async createAssociation (
125131 companyNumber : string ,
126- userId : string
132+ userId : string ,
133+ requestId ?: string
127134 ) : Promise < Resource < NewAssociationResponse | Errors > > {
128135 const url = "/associations" ;
129136 const body = { company_number : companyNumber , user_id : userId } ;
130- const response = await this . client . httpPost ( url , body ) ;
137+ const headers = addRequestIdHeader ( requestId ) ;
138+ const response = await this . client . httpPost ( url , body , headers ) ;
131139 return this . getResource ( response ) as Resource < NewAssociationResponse | Errors > ;
132140 }
133141
@@ -139,11 +147,13 @@ export default class AssociationsService {
139147 */
140148 public async inviteUser (
141149 companyNumber : string ,
142- inviteeEmailAddress : string
150+ inviteeEmailAddress : string ,
151+ requestId ?: string
143152 ) : Promise < Resource < NewAssociationResponse | Errors > > {
144153 const url = "/associations/invitations" ;
145154 const body = { company_number : companyNumber , invitee_email_id : inviteeEmailAddress } ;
146- const response = await this . client . httpPost ( url , body ) ;
155+ const headers = addRequestIdHeader ( requestId ) ;
156+ const response = await this . client . httpPost ( url , body , headers ) ;
147157 return this . getResource ( response ) as Resource < NewAssociationResponse | Errors > ;
148158 }
149159
@@ -153,11 +163,12 @@ export default class AssociationsService {
153163 * @returns a promise that resolves to the HTTP response from the server that includes the association data or errors object.
154164 */
155165 public async getAssociation (
156- associationId : string
166+ associationId : string ,
167+ requestId ?: string
157168 ) : Promise < Resource < Association | Errors > > {
158169 const url = `/associations/${ associationId } ` ;
159- const response = await this . client . httpGet ( url ) ;
160-
170+ const headers = addRequestIdHeader ( requestId ) ;
171+ const response = await this . client . httpGet ( url , headers ) ;
161172 return this . getResource ( response ) as Resource < Association | Errors > ;
162173 }
163174
@@ -169,12 +180,13 @@ export default class AssociationsService {
169180 */
170181 public async updateAssociationStatus (
171182 associationId : string ,
172- status : AssociationStatus
183+ status : AssociationStatus ,
184+ requestId ?: string
173185 ) : Promise < Resource < undefined | Errors > > {
174186 const url = `/associations/${ associationId } ` ;
175187 const body = { status : status } ;
176- const response = await this . client . httpPatch ( url , body ) ;
177-
188+ const headers = addRequestIdHeader ( requestId ) ;
189+ const response = await this . client . httpPatch ( url , body , headers ) ;
178190 return this . getResource ( response ) as Resource < undefined | Errors > ;
179191 }
180192
@@ -188,7 +200,8 @@ export default class AssociationsService {
188200 */
189201 public async getInvitations (
190202 pageIndex ?: number ,
191- itemsPerPage ?: number
203+ itemsPerPage ?: number ,
204+ requestId ?: string
192205 ) : Promise < Resource < InvitationList | Errors > > {
193206 const queryParameters : QueryParameters = {
194207 page_index : pageIndex || undefined ,
@@ -197,7 +210,9 @@ export default class AssociationsService {
197210 const queryString = this . getQueryString ( queryParameters ) ;
198211
199212 const url = `/associations/invitations${ queryString } ` ;
200- const response = await this . client . httpGet ( url ) ;
213+ const headers = addRequestIdHeader ( requestId ) ;
214+
215+ const response = await this . client . httpGet ( url , headers ) ;
201216
202217 return this . getResource ( response ) as Resource < InvitationList | Errors > ;
203218 }
@@ -210,15 +225,16 @@ export default class AssociationsService {
210225 */
211226 public async postInvitation (
212227 companyNumber : string ,
213- inviteeEmailAddress : string
228+ inviteeEmailAddress : string ,
229+ requestId ?: string
214230 ) : Promise < Resource < NewAssociationResponse | Errors > > {
215231 const body = {
216232 company_number : companyNumber ,
217233 invitee_email_id : inviteeEmailAddress
218234 } ;
219235 const url = `/associations/invitations` ;
220-
221- const response = await this . client . httpPost ( url , body ) ;
236+ const headers = addRequestIdHeader ( requestId ) ;
237+ const response = await this . client . httpPost ( url , body , headers ) ;
222238
223239 return this . getResource ( response ) as Resource < NewAssociationResponse | Errors > ;
224240 }
@@ -233,7 +249,8 @@ export default class AssociationsService {
233249 public async getPreviousStates (
234250 associationID : string ,
235251 pageIndex ?: number ,
236- itemsPerPage ?: number
252+ itemsPerPage ?: number ,
253+ requestId ?: string
237254 ) : Promise < Resource < PreviousStateList | Errors > > {
238255 let queryString : string = "" ;
239256 if ( pageIndex || itemsPerPage ) {
@@ -245,7 +262,8 @@ export default class AssociationsService {
245262 }
246263
247264 const url = `/associations/${ associationID } /previous-states${ queryString } ` ;
248- const response = await this . client . httpGet ( url ) ;
265+ const headers = addRequestIdHeader ( requestId ) ;
266+ const response = await this . client . httpGet ( url , headers ) ;
249267
250268 return this . getResource ( response ) as Resource < PreviousStateList | Errors > ;
251269 }
0 commit comments