1.0.27 • Published 1 month ago

@bitbar/cloud-api-client v1.0.27

Weekly downloads
43
License
MIT
Repository
github
Last release
1 month ago

Bitbar Cloud API Client for JavaScript

License: MIT Build Status

This repository contains official Bitbar Cloud API Client for JavaScript. Smartbear's Bitbar Cloud hosts hundreds of Android and iOS devices, enabling users to create and test high quality mobile apps and games.

Getting Started

Disclaimer

PLEASE NOTE, that project is under development (versions is below 1.0.0). Because of that not all resources are implemented and/or tested. List of working resources can be found here.

Prerequisites

This package is using UMD pattern, so it means that you can use it:

  • in Node.js project
  • browser running project

    • without AMD
    • with AMD

Concepts

The syntax of the library is heavily inspired by the Chai HTTP syntax. Understanding the following general concepts will allow you to quickly learn the syntax

1. Chaining

Most methods in library is chainable. That's means that you don't need to write long code like:

var meRef = apiClient.me();
var projectRef = me.project(1);
var runRef = project.run(2);

Rather it was designed to use it this way:

apiClient.me().project(1).run(2);

2. Every URL Part is a Method

Example: API resource to download list of device sessions of run with ID 10 in project with ID 20 will be:

GET https://cloud.bitbar.com/api/me/projects/20/runs/10/device-sessions

First part is /me (/api doesn't count because it's "directory" where API is stored). So:

apiClient.me();

Second is /projects, but next is the ID, so method will be in singular form:

apiClient.me().project(20);

Third is /runs, but again - there is the ID, so (again) singular form:

apiClient.me().project(20).run(10);

Last one is /device-dessions. Because it's kebab-case, we need to transform it to camelCase:

apiclient.me().project(20).runs(10).deviceSessions();

Now, because GET method is default one in axios, then we don't need to explicit set it (but you can if you want). So what's left is to send it:

apiclient.me().project(20).runs(10).deviceSessions().send();

3. Structure

Now that you know how to build a chaining call you probably will want to e.g. set params, or set data to send. All classes are documented so it should be easy to read docs from code.

If resource chain ends on method that is singular (so in Swagger it returns single object) then it's descendant of APIResource. It means that you can use all methods that are there.

If resource chain ends on method that is plural (so in Swagger it returns list) then it's descendant of APIList. It means that you can use all methods that are there.

Both APIResource and APIList are children of APIEntity.

4. HTTP Methods

HTTP methods are also methods.

  • If you want to send GET request then add to your chain .get().
  • If you want to send POST request then add to your chain .post().
  • If you want to send DELETE request then add to your chain .delete().

5. Send

Method .send() is sending request and returning Promise. With this kind of approach you can chain all you want. When you are ready, then just call .send().

Usage

CommonJS

npm install @bitbar/cloud-api-client --save
const CloudApiClient = require('@bitbar/cloud-api-client');

const apiClient = new CloudApiClient.API({
  cloudUrl: 'https://cloud.bitbar.com',
  apiKey: 'PASTE_HERE_YOUR_OWN_KEY'
});

apiClient.me().send().then( (resp) => {
  console.log(resp.data);
}).catch( (err) => {
  console.error(err);
});

AMD

requirejs(['cloud-api-client'], function (CloudApiClient) {
  var api = new CloudApiClient.API({
    cloudUrl: 'https://cloud.bitbar.com',
    apiKey: 'PASTE_HERE_YOUR_OWN_KEY'
  });
});

Old School

<!-- note that this is URL to version 0.8.0 -- please check which version is latest -->
<script src="https://github.com/bitbar/cloud-api-client-js/releases/download/v0.8.0/cloud-api-client.min.js"></script>
var api = new CloudApiClient.API({
  cloudUrl: 'https://cloud.bitbar.com',
  apiKey: 'PASTE_HERE_YOUR_OWN_KEY'
});

Examples

Simple examples are placed in examples directory

Documentation

https://bitbar.github.io/cloud-api-client-js/

Contribution

Checking code quality

npm run lint

Running tests

npm run test

Building

npm run build

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

1.0.27

1 month ago

1.0.26

1 month ago

1.0.25

2 months ago

1.0.24

5 months ago

1.0.23

5 months ago

1.0.19

9 months ago

1.0.18

10 months ago

1.0.17

10 months ago

1.0.16

10 months ago

1.0.22

7 months ago

1.0.21

8 months ago

1.0.20

8 months ago

1.0.15

10 months ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.9

2 years ago

1.0.11

1 year ago

1.0.10

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.56.0

2 years ago

0.55.0

2 years ago

0.55.1

2 years ago

0.54.1

2 years ago

0.54.0

2 years ago

0.53.0

3 years ago

0.51.0

3 years ago

0.51.1

3 years ago

0.50.1

3 years ago

0.52.0

3 years ago

0.50.0

3 years ago

0.49.0

3 years ago

0.47.0

3 years ago

0.46.0

3 years ago

0.45.1

3 years ago

0.45.0

3 years ago

0.44.0

3 years ago

0.43.0

3 years ago

0.42.0

3 years ago

0.43.1

3 years ago

0.41.0

3 years ago

0.40.0

3 years ago

0.39.1

3 years ago

0.38.3

3 years ago

0.38.2

3 years ago

0.38.1

3 years ago

0.38.0

3 years ago

0.37.0

3 years ago

0.35.0

3 years ago

0.34.0

3 years ago

0.33.0

3 years ago

0.32.0

3 years ago

0.31.1

3 years ago

0.31.0

3 years ago

0.30.0

3 years ago

0.29.3

3 years ago

0.29.2

3 years ago

0.29.1

3 years ago

0.29.0

3 years ago

0.28.3

3 years ago

0.28.2

3 years ago

0.28.1

3 years ago

0.28.0

3 years ago

0.27.0

3 years ago

0.26.0

3 years ago

0.25.0

3 years ago

0.24.1

3 years ago

0.24.0

3 years ago

0.23.0

4 years ago

0.22.0

4 years ago

0.21.1

4 years ago

0.21.0

4 years ago

0.20.0

4 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.17.1

4 years ago

0.17.0

4 years ago

0.16.0

4 years ago

0.15.0

4 years ago

0.14.0

4 years ago

0.13.0

4 years ago

0.12.1

4 years ago

0.12.0

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago