Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Latest commit

 

History

History
224 lines (161 loc) · 6.93 KB

LocationsApi.md

File metadata and controls

224 lines (161 loc) · 6.93 KB

LocationsApi

All URIs are relative to https://connect.squareup.com

Method HTTP request Description
createLocation POST /v2/locations CreateLocation
listLocations GET /v2/locations ListLocations
retrieveLocation GET /v2/locations/{location_id} RetrieveLocation
updateLocation PUT /v2/locations/{location_id} UpdateLocation

createLocation

Note: This endpoint is in beta.

CreateLocationResponse createLocation(body)

CreateLocation

Creates a location. For more information about locations, see Locations API Overview.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.LocationsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

LocationsApi apiInstance = new LocationsApi();
CreateLocationRequest body = new CreateLocationRequest(); // CreateLocationRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    CreateLocationResponse result = apiInstance.createLocation(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling LocationsApi#createLocation");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body CreateLocationRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CreateLocationResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

listLocations

ListLocationsResponse listLocations()

ListLocations

Provides information of all locations of a business. Most other Connect API endpoints have a required `location_id` path parameter. The `id` field of the `Location` objects returned by this endpoint correspond to that `location_id` parameter.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.LocationsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

LocationsApi apiInstance = new LocationsApi();
try {
    ListLocationsResponse result = apiInstance.listLocations();
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling LocationsApi#listLocations");
    e.printStackTrace();
}

Parameters

This endpoint does not need any parameter.

Return type

ListLocationsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

retrieveLocation

RetrieveLocationResponse retrieveLocation(locationId)

RetrieveLocation

Retrieves details of a location.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.LocationsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

LocationsApi apiInstance = new LocationsApi();
String locationId = "locationId_example"; // String | The ID of the location to retrieve.
try {
    RetrieveLocationResponse result = apiInstance.retrieveLocation(locationId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling LocationsApi#retrieveLocation");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
locationId String The ID of the location to retrieve.

Return type

RetrieveLocationResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

updateLocation

Note: This endpoint is in beta.

UpdateLocationResponse updateLocation(locationId, body)

UpdateLocation

Updates a location.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.LocationsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

LocationsApi apiInstance = new LocationsApi();
String locationId = "locationId_example"; // String | The ID of the location to update.
UpdateLocationRequest body = new UpdateLocationRequest(); // UpdateLocationRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    UpdateLocationResponse result = apiInstance.updateLocation(locationId, body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling LocationsApi#updateLocation");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
locationId String The ID of the location to update.
body UpdateLocationRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpdateLocationResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json