Skip to content

Commit

Permalink
Merge pull request #34 from marverix/master
Browse files Browse the repository at this point in the history
Added changes for SDCC-115
  • Loading branch information
Marek Sierociński authored Dec 2, 2020
2 parents 451fd43 + bc68ec1 commit a620d72
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 23 deletions.
3 changes: 2 additions & 1 deletion dist/api/APIListServices.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import APIListPurchased from './APIListPurchased';
declare class APIListServices extends APIList {
constructor(parent: object);
purchased(): APIListPurchased;
available(): void;
available(): APIList;
active(): APIList;
}
export default APIListServices;
8 changes: 8 additions & 0 deletions dist/api/APIResourceAccountService.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import APIResource from './APIResource';
declare class APIResourceAccountService extends APIResource {
constructor(parent: object, id: number);
activate(): APIResource;
deactivate(): APIResource;
billingPeriod(): APIResource;
}
export default APIResourceAccountService;
4 changes: 3 additions & 1 deletion dist/api/APIResourceUser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import APIListFiles from './APIListFiles';
import APIListServices from './APIListServices';
import APIListRuns from './APIListRuns';
import APIListNotifications from './APIListNotifications';
import APIResourceAccountService from './APIResourceAccountService';
declare class APIResourceUser extends APIResource {
constructor(parent: object, id: number | 'me');
account(): APIResourceAccount;
deviceTime(): APIListDeviceTime;
deviceTimeSummary(): APIList;
services(): APIListServices;
service(id: number): APIResource;
accountServiceBillingPeriod(id: number): APIResource;
accountServices(): APIList;
accountService(id: number): APIResourceAccountService;
billingPeriods(): APIList;
billingPeriod(id: number): APIResourceBillingPeriod;
jobs(): APIList;
Expand Down
47 changes: 39 additions & 8 deletions dist/bitbar-cloud-api-client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/bitbar-cloud-api-client.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/bitbar-cloud-api-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bitbar-cloud-api-client.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitbar/cloud-api-client",
"version": "0.23.0",
"version": "0.24.0",
"description": "Bitbar Cloud API Client for JavaScript",
"main": "dist/bitbar-cloud-api-client.min.js",
"types": "dist/index.d.ts",
Expand Down
14 changes: 13 additions & 1 deletion src/api/APIListServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ class APIListServices extends APIList {

// /services/available
public available () {
this.push('available');
return new APIList(this).push('available');
}

public active () {
const a = new APIList(this);
if (this.stack[0] === 'me') {
a.push('active');
} else {
a.params({
notArchived: true
});
}
return a;
}

}
Expand Down
42 changes: 42 additions & 0 deletions src/api/APIResourceAccountService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import APIResource from './APIResource'

/**
* APIResourceAccountService
*
* @class
* @extends APIResource
*/
class APIResourceAccountService extends APIResource {

/**
* /account-services/{id}
*
* Constructor
*/
constructor (parent: object, id: number) {
if (id == null) {
throw new Error('Resource ID cannot be null!');
}

super(parent);
this.push('account-services', id);
}

// /account-services/{id}/activate
public activate () {
return new APIResource(this).push('activate');
}

// /account-services/{id}/deactivate
public deactivate () {
return new APIResource(this).push('deactivate');
}

// /account-services/{id}/billing-period
public billingPeriod () {
return new APIResource(this).push('billing-period');
}

}

export default APIResourceAccountService
14 changes: 8 additions & 6 deletions src/api/APIResourceUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import APIListFiles from './APIListFiles'
import APIListServices from './APIListServices'
import APIListRuns from './APIListRuns'
import APIListNotifications from './APIListNotifications'
import APIResourceAccountService from './APIResourceAccountService';


/**
Expand Down Expand Up @@ -75,13 +76,14 @@ class APIResourceUser extends APIResource {
return new APIResource(this).push('services', id);
}

// /users/{id}/account-services/{id}/billing-period
public accountServiceBillingPeriod (id: number) {
if (id == null) {
throw new Error('Resource ID cannot be null!');
}
// /users/{id}/account-services
public accountServices () {
return new APIList(this).push('account-services');
}

return new APIResource(this).push('account-services', id, 'billing-period');
// /users/{id}/account-services/{id}
public accountService (id: number) {
return new APIResourceAccountService(this, id);
}

// /users/{id}/billing-periods
Expand Down

0 comments on commit a620d72

Please sign in to comment.