Skip to content

Latest commit

 

History

History
711 lines (572 loc) · 19.8 KB

team.md

File metadata and controls

711 lines (572 loc) · 19.8 KB

Team

ITeamApi teamApi = client.TeamApi;

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.

CreateTeamMemberAsync(
    Models.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

Task<Models.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(
            new List<string>
            {
                "YSGH2WBKG94QZ",
                "GA2Y9HSJ8KRYT",
            })
        .Build())
    .WageSetting(
        new WageSetting.Builder()
        .JobAssignments(
            new List<JobAssignment>
            {
                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();

try
{
    CreateTeamMemberResponse result = await teamApi.CreateTeamMemberAsync(body);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

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.

BulkCreateTeamMembersAsync(
    Models.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

Task<Models.BulkCreateTeamMembersResponse>

Example Usage

BulkCreateTeamMembersRequest body = new BulkCreateTeamMembersRequest.Builder(
    new Dictionary<string, CreateTeamMemberRequest>
    {
        ["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(
                    new List<string>
                    {
                        "YSGH2WBKG94QZ",
                        "GA2Y9HSJ8KRYT",
                    })
                .Build())
            .Build())
        .Build(),
        ["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();

try
{
    BulkCreateTeamMembersResponse result = await teamApi.BulkCreateTeamMembersAsync(body);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

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.

BulkUpdateTeamMembersAsync(
    Models.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

Task<Models.BulkUpdateTeamMembersResponse>

Example Usage

BulkUpdateTeamMembersRequest body = new BulkUpdateTeamMembersRequest.Builder(
    new Dictionary<string, UpdateTeamMemberRequest>
    {
        ["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(),
        ["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(
                    new List<string>
                    {
                        "YSGH2WBKG94QZ",
                        "GA2Y9HSJ8KRYT",
                    })
                .Build())
            .Build())
        .Build(),
    }
)
.Build();

try
{
    BulkUpdateTeamMembersResponse result = await teamApi.BulkUpdateTeamMembersAsync(body);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

List Jobs

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

ListJobsAsync(
    string cursor = null)

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

Task<Models.ListJobsResponse>

Example Usage

try
{
    ListJobsResponse result = await teamApi.ListJobsAsync();
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

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.

CreateJobAsync(
    Models.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

Task<Models.CreateJobResponse>

Example Usage

CreateJobRequest body = new CreateJobRequest.Builder(
    new Job.Builder()
    .Title("Cashier")
    .IsTipEligible(true)
    .Build(),
    "idempotency-key-0"
)
.Build();

try
{
    CreateJobResponse result = await teamApi.CreateJobAsync(body);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Retrieve Job

Retrieves a specified job.

RetrieveJobAsync(
    string jobId)

Parameters

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

Response Type

Task<Models.RetrieveJobResponse>

Example Usage

string jobId = "job_id2";
try
{
    RetrieveJobResponse result = await teamApi.RetrieveJobAsync(jobId);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

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.

UpdateJobAsync(
    string jobId,
    Models.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

Task<Models.UpdateJobResponse>

Example Usage

string jobId = "job_id2";
UpdateJobRequest body = new UpdateJobRequest.Builder(
    new Job.Builder()
    .Title("Cashier 1")
    .IsTipEligible(true)
    .Build()
)
.Build();

try
{
    UpdateJobResponse result = await teamApi.UpdateJobAsync(
        jobId,
        body
    );
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

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.

SearchTeamMembersAsync(
    Models.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

Task<Models.SearchTeamMembersResponse>

Example Usage

SearchTeamMembersRequest body = new SearchTeamMembersRequest.Builder()
.Query(
    new SearchTeamMembersQuery.Builder()
    .Filter(
        new SearchTeamMembersFilter.Builder()
        .LocationIds(
            new List<string>
            {
                "0G5P3VGACMMQZ",
            })
        .Status("ACTIVE")
        .Build())
    .Build())
.Limit(10)
.Build();

try
{
    SearchTeamMembersResponse result = await teamApi.SearchTeamMembersAsync(body);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Retrieve Team Member

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

RetrieveTeamMemberAsync(
    string teamMemberId)

Parameters

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

Response Type

Task<Models.RetrieveTeamMemberResponse>

Example Usage

string teamMemberId = "team_member_id0";
try
{
    RetrieveTeamMemberResponse result = await teamApi.RetrieveTeamMemberAsync(teamMemberId);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Update Team Member

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

UpdateTeamMemberAsync(
    string teamMemberId,
    Models.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

Task<Models.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(
            new List<string>
            {
                "YSGH2WBKG94QZ",
                "GA2Y9HSJ8KRYT",
            })
        .Build())
    .Build())
.Build();

try
{
    UpdateTeamMemberResponse result = await teamApi.UpdateTeamMemberAsync(
        teamMemberId,
        body
    );
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

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.

RetrieveWageSettingAsync(
    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

Task<Models.RetrieveWageSettingResponse>

Example Usage

string teamMemberId = "team_member_id0";
try
{
    RetrieveWageSettingResponse result = await teamApi.RetrieveWageSettingAsync(teamMemberId);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

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.

UpdateWageSettingAsync(
    string teamMemberId,
    Models.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

Task<Models.UpdateWageSettingResponse>

Example Usage

string teamMemberId = "team_member_id0";
UpdateWageSettingRequest body = new UpdateWageSettingRequest.Builder(
    new WageSetting.Builder()
    .JobAssignments(
        new List<JobAssignment>
        {
            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();

try
{
    UpdateWageSettingResponse result = await teamApi.UpdateWageSettingAsync(
        teamMemberId,
        body
    );
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}