Skip to content

Latest commit

 

History

History
658 lines (516 loc) · 21.1 KB

team.md

File metadata and controls

658 lines (516 loc) · 21.1 KB

Team

TeamApi teamApi = client.getTeamApi();

Class Name

TeamApi

Methods

Create Team Member

Creates a single TeamMember object. The TeamMember object is returned on successful creates. You must provide the following values in your request to this endpoint:

  • given_name
  • family_name

Learn about Troubleshooting the Team API.

CompletableFuture<CreateTeamMemberResponse> createTeamMemberAsync(
    final CreateTeamMemberRequest body)

Parameters

Parameter Type Tags Description
body CreateTeamMemberRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

CreateTeamMemberResponse

Example Usage

CreateTeamMemberRequest body = new CreateTeamMemberRequest.Builder()
    .idempotencyKey("idempotency-key-0")
    .teamMember(new TeamMember.Builder()
        .referenceId("reference_id_1")
        .status("ACTIVE")
        .givenName("Joe")
        .familyName("Doe")
        .emailAddress("[email protected]")
        .phoneNumber("+14159283333")
        .assignedLocations(new TeamMemberAssignedLocations.Builder()
            .assignmentType("EXPLICIT_LOCATIONS")
            .locationIds(Arrays.asList(
                "YSGH2WBKG94QZ",
                "GA2Y9HSJ8KRYT"
            ))
            .build())
        .wageSetting(new WageSetting.Builder()
            .jobAssignments(Arrays.asList(
                new JobAssignment.Builder(
                    "SALARY"
                )
                .annualRate(new Money.Builder()
                        .amount(3000000L)
                        .currency("USD")
                        .build())
                .weeklyHours(40)
                .jobId("FjS8x95cqHiMenw4f1NAUH4P")
                .build(),
                new JobAssignment.Builder(
                    "HOURLY"
                )
                .hourlyRate(new Money.Builder()
                        .amount(2000L)
                        .currency("USD")
                        .build())
                .jobId("VDNpRv8da51NU8qZFC5zDWpF")
                .build()
            ))
            .isOvertimeExempt(true)
            .build())
        .build())
    .build();

teamApi.createTeamMemberAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Bulk Create Team Members

Creates multiple TeamMember objects. The created TeamMember objects are returned on successful creates. This process is non-transactional and processes as much of the request as possible. If one of the creates in the request cannot be successfully processed, the request is not marked as failed, but the body of the response contains explicit error information for the failed create.

Learn about Troubleshooting the Team API.

CompletableFuture<BulkCreateTeamMembersResponse> bulkCreateTeamMembersAsync(
    final BulkCreateTeamMembersRequest body)

Parameters

Parameter Type Tags Description
body BulkCreateTeamMembersRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

BulkCreateTeamMembersResponse

Example Usage

BulkCreateTeamMembersRequest body = new BulkCreateTeamMembersRequest.Builder(
    new LinkedHashMap<String, CreateTeamMemberRequest>() {{
        put("idempotency-key-1", new CreateTeamMemberRequest.Builder()
            .teamMember(new TeamMember.Builder()
                .referenceId("reference_id_1")
                .givenName("Joe")
                .familyName("Doe")
                .emailAddress("[email protected]")
                .phoneNumber("+14159283333")
                .assignedLocations(new TeamMemberAssignedLocations.Builder()
                    .assignmentType("EXPLICIT_LOCATIONS")
                    .locationIds(Arrays.asList(
                        "YSGH2WBKG94QZ",
                        "GA2Y9HSJ8KRYT"
                    ))
                    .build())
                .build())
            .build());
        put("idempotency-key-2", new CreateTeamMemberRequest.Builder()
            .teamMember(new TeamMember.Builder()
                .referenceId("reference_id_2")
                .givenName("Jane")
                .familyName("Smith")
                .emailAddress("[email protected]")
                .phoneNumber("+14159223334")
                .assignedLocations(new TeamMemberAssignedLocations.Builder()
                    .assignmentType("ALL_CURRENT_AND_FUTURE_LOCATIONS")
                    .build())
                .build())
            .build());
    }}
)
.build();

teamApi.bulkCreateTeamMembersAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Bulk Update Team Members

Updates multiple TeamMember objects. The updated TeamMember objects are returned on successful updates. This process is non-transactional and processes as much of the request as possible. If one of the updates in the request cannot be successfully processed, the request is not marked as failed, but the body of the response contains explicit error information for the failed update. Learn about Troubleshooting the Team API.

CompletableFuture<BulkUpdateTeamMembersResponse> bulkUpdateTeamMembersAsync(
    final BulkUpdateTeamMembersRequest body)

Parameters

Parameter Type Tags Description
body BulkUpdateTeamMembersRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

BulkUpdateTeamMembersResponse

Example Usage

BulkUpdateTeamMembersRequest body = new BulkUpdateTeamMembersRequest.Builder(
    new LinkedHashMap<String, UpdateTeamMemberRequest>() {{
        put("AFMwA08kR-MIF-3Vs0OE", new UpdateTeamMemberRequest.Builder()
            .teamMember(new TeamMember.Builder()
                .referenceId("reference_id_2")
                .status("ACTIVE")
                .givenName("Jane")
                .familyName("Smith")
                .emailAddress("[email protected]")
                .phoneNumber("+14159223334")
                .assignedLocations(new TeamMemberAssignedLocations.Builder()
                    .assignmentType("ALL_CURRENT_AND_FUTURE_LOCATIONS")
                    .build())
                .build())
            .build());
        put("fpgteZNMaf0qOK-a4t6P", new UpdateTeamMemberRequest.Builder()
            .teamMember(new TeamMember.Builder()
                .referenceId("reference_id_1")
                .status("ACTIVE")
                .givenName("Joe")
                .familyName("Doe")
                .emailAddress("[email protected]")
                .phoneNumber("+14159283333")
                .assignedLocations(new TeamMemberAssignedLocations.Builder()
                    .assignmentType("EXPLICIT_LOCATIONS")
                    .locationIds(Arrays.asList(
                        "YSGH2WBKG94QZ",
                        "GA2Y9HSJ8KRYT"
                    ))
                    .build())
                .build())
            .build());
    }}
)
.build();

teamApi.bulkUpdateTeamMembersAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

List Jobs

Lists jobs in a seller account. Results are sorted by title in ascending order.

CompletableFuture<ListJobsResponse> listJobsAsync(
    final String cursor)

Parameters

Parameter Type Tags Description
cursor String Query, Optional The pagination cursor returned by the previous call to this endpoint. Provide this
cursor to retrieve the next page of results for your original request. For more information,
see Pagination.

Response Type

ListJobsResponse

Example Usage

teamApi.listJobsAsync(null).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Create Job

Creates a job in a seller account. A job defines a title and tip eligibility. Note that compensation is defined in a job assignment in a team member's wage setting.

CompletableFuture<CreateJobResponse> createJobAsync(
    final CreateJobRequest body)

Parameters

Parameter Type Tags Description
body CreateJobRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

CreateJobResponse

Example Usage

CreateJobRequest body = new CreateJobRequest.Builder(
    new Job.Builder()
        .title("Cashier")
        .isTipEligible(true)
        .build(),
    "idempotency-key-0"
)
.build();

teamApi.createJobAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Retrieve Job

Retrieves a specified job.

CompletableFuture<RetrieveJobResponse> retrieveJobAsync(
    final String jobId)

Parameters

Parameter Type Tags Description
jobId String Template, Required The ID of the job to retrieve.

Response Type

RetrieveJobResponse

Example Usage

String jobId = "job_id2";

teamApi.retrieveJobAsync(jobId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Update Job

Updates the title or tip eligibility of a job. Changes to the title propagate to all JobAssignment, Shift, and TeamMemberWage objects that reference the job ID. Changes to tip eligibility propagate to all TeamMemberWage objects that reference the job ID.

CompletableFuture<UpdateJobResponse> updateJobAsync(
    final String jobId,
    final UpdateJobRequest body)

Parameters

Parameter Type Tags Description
jobId String Template, Required The ID of the job to update.
body UpdateJobRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

UpdateJobResponse

Example Usage

String jobId = "job_id2";
UpdateJobRequest body = new UpdateJobRequest.Builder(
    new Job.Builder()
        .title("Cashier 1")
        .isTipEligible(true)
        .build()
)
.build();

teamApi.updateJobAsync(jobId, body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Search Team Members

Returns a paginated list of TeamMember objects for a business. The list can be filtered by location IDs, ACTIVE or INACTIVE status, or whether the team member is the Square account owner.

CompletableFuture<SearchTeamMembersResponse> searchTeamMembersAsync(
    final SearchTeamMembersRequest body)

Parameters

Parameter Type Tags Description
body SearchTeamMembersRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

SearchTeamMembersResponse

Example Usage

SearchTeamMembersRequest body = new SearchTeamMembersRequest.Builder()
    .query(new SearchTeamMembersQuery.Builder()
        .filter(new SearchTeamMembersFilter.Builder()
            .locationIds(Arrays.asList(
                "0G5P3VGACMMQZ"
            ))
            .status("ACTIVE")
            .build())
        .build())
    .limit(10)
    .build();

teamApi.searchTeamMembersAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Retrieve Team Member

Retrieves a TeamMember object for the given TeamMember.id. Learn about Troubleshooting the Team API.

CompletableFuture<RetrieveTeamMemberResponse> retrieveTeamMemberAsync(
    final String teamMemberId)

Parameters

Parameter Type Tags Description
teamMemberId String Template, Required The ID of the team member to retrieve.

Response Type

RetrieveTeamMemberResponse

Example Usage

String teamMemberId = "team_member_id0";

teamApi.retrieveTeamMemberAsync(teamMemberId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Update Team Member

Updates a single TeamMember object. The TeamMember object is returned on successful updates. Learn about Troubleshooting the Team API.

CompletableFuture<UpdateTeamMemberResponse> updateTeamMemberAsync(
    final String teamMemberId,
    final UpdateTeamMemberRequest body)

Parameters

Parameter Type Tags Description
teamMemberId String Template, Required The ID of the team member to update.
body UpdateTeamMemberRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

UpdateTeamMemberResponse

Example Usage

String teamMemberId = "team_member_id0";
UpdateTeamMemberRequest body = new UpdateTeamMemberRequest.Builder()
    .teamMember(new TeamMember.Builder()
        .referenceId("reference_id_1")
        .status("ACTIVE")
        .givenName("Joe")
        .familyName("Doe")
        .emailAddress("[email protected]")
        .phoneNumber("+14159283333")
        .assignedLocations(new TeamMemberAssignedLocations.Builder()
            .assignmentType("EXPLICIT_LOCATIONS")
            .locationIds(Arrays.asList(
                "YSGH2WBKG94QZ",
                "GA2Y9HSJ8KRYT"
            ))
            .build())
        .build())
    .build();

teamApi.updateTeamMemberAsync(teamMemberId, body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Retrieve Wage Setting

Retrieves a WageSetting object for a team member specified by TeamMember.id. For more information, see Troubleshooting the Team API.

Square recommends using RetrieveTeamMember or SearchTeamMembers to get this information directly from the TeamMember.wage_setting field.

CompletableFuture<RetrieveWageSettingResponse> retrieveWageSettingAsync(
    final String teamMemberId)

Parameters

Parameter Type Tags Description
teamMemberId String Template, Required The ID of the team member for which to retrieve the wage setting.

Response Type

RetrieveWageSettingResponse

Example Usage

String teamMemberId = "team_member_id0";

teamApi.retrieveWageSettingAsync(teamMemberId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Update Wage Setting

Creates or updates a WageSetting object. The object is created if a WageSetting with the specified team_member_id doesn't exist. Otherwise, it fully replaces the WageSetting object for the team member. The WageSetting is returned on a successful update. For more information, see Troubleshooting the Team API.

Square recommends using CreateTeamMember or UpdateTeamMember to manage the TeamMember.wage_setting field directly.

CompletableFuture<UpdateWageSettingResponse> updateWageSettingAsync(
    final String teamMemberId,
    final UpdateWageSettingRequest body)

Parameters

Parameter Type Tags Description
teamMemberId String Template, Required The ID of the team member for which to update the WageSetting object.
body UpdateWageSettingRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

UpdateWageSettingResponse

Example Usage

String teamMemberId = "team_member_id0";
UpdateWageSettingRequest body = new UpdateWageSettingRequest.Builder(
    new WageSetting.Builder()
        .jobAssignments(Arrays.asList(
            new JobAssignment.Builder(
                "SALARY"
            )
            .jobTitle("Manager")
            .annualRate(new Money.Builder()
                    .amount(3000000L)
                    .currency("USD")
                    .build())
            .weeklyHours(40)
            .build(),
            new JobAssignment.Builder(
                "HOURLY"
            )
            .jobTitle("Cashier")
            .hourlyRate(new Money.Builder()
                    .amount(2000L)
                    .currency("USD")
                    .build())
            .build()
        ))
        .isOvertimeExempt(true)
        .build()
)
.build();

teamApi.updateWageSettingAsync(teamMemberId, body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});