Skip to content

Commit a355748

Browse files
author
Phrase
committed
1 parent 60d5d47 commit a355748

File tree

5 files changed

+127
-4
lines changed

5 files changed

+127
-4
lines changed

.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ src/models/BlacklistedKey.ts
7777
src/models/BlacklistedKeyCreateParameters.ts
7878
src/models/BlacklistedKeyUpdateParameters.ts
7979
src/models/Branch.ts
80+
src/models/BranchCreateComparisonParameters.ts
8081
src/models/BranchCreateParameters.ts
8182
src/models/BranchMergeParameters.ts
8283
src/models/BranchName.ts

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ Class | Method | HTTP request | Description
219219
*BlacklistedKeysApi* | **blacklistedKeyUpdate** | **PATCH** /projects/{project_id}/blacklisted_keys/{id} | Update a blocked key
220220
*BlacklistedKeysApi* | **blacklistedKeysList** | **GET** /projects/{project_id}/blacklisted_keys | List blocked keys
221221
*BranchesApi* | **branchCompare** | **GET** /projects/{project_id}/branches/{name}/compare | Compare branches
222+
*BranchesApi* | **branchComparisonCreate** | **POST** /projects/{project_id}/branches/{name}/compare | Create comparison (async.)
222223
*BranchesApi* | **branchCreate** | **POST** /projects/{project_id}/branches | Create a branch
223224
*BranchesApi* | **branchDelete** | **DELETE** /projects/{project_id}/branches/{name} | Delete a branch
224225
*BranchesApi* | **branchMerge** | **PATCH** /projects/{project_id}/branches/{name}/merge | Merge a branch

src/apis/BranchesApi.ts

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import {
1717
Branch,
1818
BranchFromJSON,
1919
BranchToJSON,
20+
BranchCreateComparisonParameters,
21+
BranchCreateComparisonParametersFromJSON,
22+
BranchCreateComparisonParametersToJSON,
2023
BranchCreateParameters,
2124
BranchCreateParametersFromJSON,
2225
BranchCreateParametersToJSON,
@@ -37,6 +40,13 @@ export interface BranchCompareRequest {
3740
xPhraseAppOTP?: string;
3841
}
3942

43+
export interface BranchComparisonCreateRequest {
44+
projectId: string;
45+
name: string;
46+
branchCreateComparisonParameters: BranchCreateComparisonParameters;
47+
xPhraseAppOTP?: string;
48+
}
49+
4050
export interface BranchCreateRequest {
4151
projectId: string;
4252
branchCreateParameters: BranchCreateParameters;
@@ -89,7 +99,7 @@ export interface BranchesListRequest {
8999
export class BranchesApi extends runtime.BaseAPI {
90100

91101
/**
92-
* Compare branch with main branch. *Note: Comparing a branch may take several minutes depending on the project size.*
102+
* Compare branch with main branch. *Note: Comparing a branch may take several minutes depending on the project size. Consider using the `POST /compare` endpoint for creating comparison asynchronously.*
93103
* Compare branches
94104
*/
95105
async branchCompareRaw(requestParameters: BranchCompareRequest): Promise<runtime.ApiResponse<any>> {
@@ -127,14 +137,68 @@ export class BranchesApi extends runtime.BaseAPI {
127137
}
128138

129139
/**
130-
* Compare branch with main branch. *Note: Comparing a branch may take several minutes depending on the project size.*
140+
* Compare branch with main branch. *Note: Comparing a branch may take several minutes depending on the project size. Consider using the `POST /compare` endpoint for creating comparison asynchronously.*
131141
* Compare branches
132142
*/
133143
async branchCompare(requestParameters: BranchCompareRequest): Promise<any> {
134144
const response = await this.branchCompareRaw(requestParameters);
135145
return await response.value();
136146
}
137147

148+
/**
149+
* Create a branch comparison asynchronously.
150+
* Create comparison (async.)
151+
*/
152+
async branchComparisonCreateRaw(requestParameters: BranchComparisonCreateRequest): Promise<runtime.ApiResponse<any>> {
153+
if (requestParameters.projectId === null || requestParameters.projectId === undefined) {
154+
throw new runtime.RequiredError('projectId','Required parameter requestParameters.projectId was null or undefined when calling branchComparisonCreate.');
155+
}
156+
157+
if (requestParameters.name === null || requestParameters.name === undefined) {
158+
throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling branchComparisonCreate.');
159+
}
160+
161+
if (requestParameters.branchCreateComparisonParameters === null || requestParameters.branchCreateComparisonParameters === undefined) {
162+
throw new runtime.RequiredError('branchCreateComparisonParameters','Required parameter requestParameters.branchCreateComparisonParameters was null or undefined when calling branchComparisonCreate.');
163+
}
164+
165+
const queryParameters: any = {};
166+
167+
const headerParameters: runtime.HTTPHeaders = {};
168+
169+
headerParameters['Content-Type'] = 'application/json';
170+
171+
if (requestParameters.xPhraseAppOTP !== undefined && requestParameters.xPhraseAppOTP !== null) {
172+
headerParameters['X-PhraseApp-OTP'] = String(requestParameters.xPhraseAppOTP);
173+
}
174+
175+
if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
176+
headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
177+
}
178+
if (this.configuration && this.configuration.apiKey) {
179+
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // Token authentication
180+
}
181+
182+
const response = await this.request({
183+
path: `/projects/{project_id}/branches/{name}/compare`.replace(`{${"project_id"}}`, encodeURIComponent(String(requestParameters.projectId))).replace(`{${"name"}}`, encodeURIComponent(String(requestParameters.name))),
184+
method: 'POST',
185+
headers: headerParameters,
186+
query: queryParameters,
187+
body: BranchCreateComparisonParametersToJSON(requestParameters.branchCreateComparisonParameters),
188+
});
189+
190+
return new runtime.TextApiResponse(response) as any;
191+
}
192+
193+
/**
194+
* Create a branch comparison asynchronously.
195+
* Create comparison (async.)
196+
*/
197+
async branchComparisonCreate(requestParameters: BranchComparisonCreateRequest): Promise<any> {
198+
const response = await this.branchComparisonCreateRaw(requestParameters);
199+
return await response.value();
200+
}
201+
138202
/**
139203
* Create a new branch. *Note: Creating a new branch may take several minutes depending on the project size.*
140204
* Create a branch
@@ -334,7 +398,7 @@ export class BranchesApi extends runtime.BaseAPI {
334398
}
335399

336400
/**
337-
* Sync an existing branch. *Note: Only available for branches created with new branching. New branching is currently in private beta*
401+
* Sync an existing branch. *Note: Only available for branches created with new branching.*
338402
* Sync a branch
339403
*/
340404
async branchSyncRaw(requestParameters: BranchSyncRequest): Promise<runtime.ApiResponse<any>> {
@@ -379,7 +443,7 @@ export class BranchesApi extends runtime.BaseAPI {
379443
}
380444

381445
/**
382-
* Sync an existing branch. *Note: Only available for branches created with new branching. New branching is currently in private beta*
446+
* Sync an existing branch. *Note: Only available for branches created with new branching.*
383447
* Sync a branch
384448
*/
385449
async branchSync(requestParameters: BranchSyncRequest): Promise<any> {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Phrase Strings API Reference
5+
*
6+
* The version of the OpenAPI document: 2.0.0
7+
* Contact: support@phrase.com
8+
*
9+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10+
* https://openapi-generator.tech
11+
* Do not edit the class manually.
12+
*/
13+
14+
import { exists, mapValues } from '../runtime';
15+
/**
16+
*
17+
* @export
18+
* @interface BranchCreateComparisonParameters
19+
*/
20+
export interface BranchCreateComparisonParameters {
21+
/**
22+
* direction of comparison, possible values are sync or merge (only for v2 branches)
23+
* @type {string}
24+
* @memberof BranchCreateComparisonParameters
25+
*/
26+
direction?: string;
27+
}
28+
29+
export function BranchCreateComparisonParametersFromJSON(json: any): BranchCreateComparisonParameters {
30+
return BranchCreateComparisonParametersFromJSONTyped(json, false);
31+
}
32+
33+
export function BranchCreateComparisonParametersFromJSONTyped(json: any, ignoreDiscriminator: boolean): BranchCreateComparisonParameters {
34+
if ((json === undefined) || (json === null)) {
35+
return json;
36+
}
37+
return {
38+
39+
'direction': !exists(json, 'direction') ? undefined : json['direction'],
40+
};
41+
}
42+
43+
export function BranchCreateComparisonParametersToJSON(value?: BranchCreateComparisonParameters | null): any {
44+
if (value === undefined) {
45+
return undefined;
46+
}
47+
if (value === null) {
48+
return null;
49+
}
50+
return {
51+
52+
'direction': value.direction,
53+
};
54+
}
55+
56+

src/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './BlacklistedKey';
1414
export * from './BlacklistedKeyCreateParameters';
1515
export * from './BlacklistedKeyUpdateParameters';
1616
export * from './Branch';
17+
export * from './BranchCreateComparisonParameters';
1718
export * from './BranchCreateParameters';
1819
export * from './BranchMergeParameters';
1920
export * from './BranchName';

0 commit comments

Comments
 (0)