6.5.1 • Published 8 months ago

@openfn/language-http v6.5.1

Weekly downloads
161
License
LGPLv3
Repository
github
Last release
8 months ago

Language HTTP

Language Pack for building expressions and operations to make HTTP calls.

Documentation

Configuration

View all the required and optional properties for state.configuration in the official configuration-schema definition.

Get data

This helper function allows the use of a get method to fetch data. You can specify a query string for filter.

get(
  '/myendpoint',
  {
    query: { foo: 'bar', a: 1 },
    headers: { 'content-type': 'application/json' },
    authentication: { username: 'taylor', password: 'somethingsecret' },
  },
  state => {
    return state;
  }
);

Post existing data

Send some data to an existing endpoint.

post('/endpoint', {
  body: state => {
    return {
      field_1: 'some_data',
      field_2: 'some_more_data',
      field_id: dataValue('Some.Json.Object.Id')(state),
    };
  },
  headers: {
    Authorization: 'AUTH_KEY',
    'Content-Type': 'application/json',
  },
});

Update existing data with PUT or PATCH

put(
  '/myendpoint',
  {
    body: { firstname: 'taylor', lastname: 'downs' },
    headers: { 'content-type': 'application/json' },
    authentication: { username: 'user', password: 'pass' },
  },
  state => {
    return state;
  }
);
patch(
  '/myendpoint',
  {
    body: { firstname: 'taylor', lastname: 'downs' },
    headers: { 'content-type': 'application/json' },
    authentication: { username: 'user', password: 'pass' },
  },
  state => {
    return state;
  }
);

Delete data

del(
  '/myendpoint',
  {
    query: { id: 'someId' },
    headers: { 'content-type': 'application/json' },
    authentication: { username: 'user', password: 'pass' },
  },
  state => {
    return state;
  }
);

Parse XML

This function allows you to parse some xml data. A callback function can be use to store in a table.

parseXML(body, function ($) {
  return $('table[class=your_table]').parsetable(true, true, true);
});

Parse CSV

parseCSV('someData.csv', {
  quoteChar: '"',
  header: false,
});

Sample parse local CSV file

parseCSV('PatientsJan2009.csv', {
  quoteChar: '"',
  header: false,
  columns: true,
  skip_empty_lines: true,
  trim: true,
  bom: true,
});

Development

Clone the repo, run pnpm install.

Run tests using pnpm run test or pnpm run test:watch.

To build the docs for this repo, run pnpm build:docs.

6.5.1

8 months ago

6.5.0

8 months ago

6.4.6

8 months ago

6.4.5

8 months ago

6.4.4

9 months ago

6.3.0

1 year ago

6.4.3

10 months ago

6.4.2

11 months ago

6.4.1

11 months ago

6.2.3

1 year ago

6.4.0

12 months ago

6.2.2

1 year ago

6.2.1

1 year ago

6.2.0

1 year ago

6.1.0

1 year ago

6.0.0

1 year ago

5.1.1

2 years ago

5.0.4

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

5.1.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.3.3

2 years ago

4.3.2

2 years ago

4.3.1

2 years ago

4.2.7

2 years ago

4.2.8

2 years ago

4.2.6

2 years ago

4.2.5

2 years ago

4.2.4

2 years ago

4.2.3

3 years ago

4.2.2

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.2.1

3 years ago

4.2.0

3 years ago

4.0.2

3 years ago

3.2.0

3 years ago

4.0.0

3 years ago

3.1.12

3 years ago

3.1.11

4 years ago

3.1.10

4 years ago

3.1.7

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.2

4 years ago

3.0.0

4 years ago