square_connect 2.0.0-dev.5 copy "square_connect: ^2.0.0-dev.5" to clipboard
square_connect: ^2.0.0-dev.5 copied to clipboard

outdated

A wrapper for the Square Connect APIs. It's intended use is in a flutter application to manage inventory, catalog, customers, labor, and more on the Square platform.

Pub GitHub PRs Welcome

Square Connect Flutter #

This package allows Dart developers to easily interact with Square APIs.

NOTE! #

Due to the way Square authenticates it's API, DO NOT use this package in Flutter apps! There is currently no supported way to securely store API tokens on the client device. This package is entirely for server-side Dart applicatations like those created with the Dart Functions Framework.

Currently only Locations API is supported, but plans are to have all Square APIs supported.

Usage #

  1. Create Square API Client.
final client = SquareApiClient(
  accessToken: 'ACCESS_TOKEN', // Make SURE this is kept secret
  apiVersion: '2021-09-15', // Optional. If ommited latest api will be used.
);
  1. Call Square APIs.
final locations = await client.listLocations();

Errors #

Instead of throwing errors caused by Square's API, methods return a list of errors returned by Square's API. To check if errors were thrown, you can call .hasErrors on the Response object, or simply check if the errors property is null.

Example

import 'package:square_connect/square_connect.dart';

async listCustomers() {
  String response = await CustomBackend.listCustomers();

  var responseObj = ListCustomersResponse.fromJson(json.decode(reponse));

  if (responseObj.hasErrors) {
    throw new Error(responseObj.errors)
  } else {
    return responseObj.customers;
  }
}

Pagination #

If pagination is supported/needed, the response object will contain a cursor string returned by Square's API. To retrieve it, you can call response.cursor. If the field is null, then no cursor exists and there are no more items to be returned. If it was not null, you can pass it into another call of the specific method.

Contributions #

If you have any feedback on how to improve the package for usablility, or bugs to report, please do so at https://github.com/mtwichel/square-connect-flutter-library/issues.

5
likes
0
pub points
63%
popularity

Publisher

unverified uploader

A wrapper for the Square Connect APIs. It's intended use is in a flutter application to manage inventory, catalog, customers, labor, and more on the Square platform.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dio, equatable, json_annotation, retrofit

More

Packages that depend on square_connect