Skip to content

Latest commit

 

History

History
316 lines (242 loc) · 20.2 KB

README.md

File metadata and controls

316 lines (242 loc) · 20.2 KB

Customers

(Customers)

Overview

Available Operations

  • List - Retrieve a list of customers
  • Create - Create a customer ⚠️ Deprecated
  • Get - Retrieve a customer
  • Update - Update a customer
  • Delete - Delete a customer

List

Retrieve a list of customers for the authenticated workspace.

Example Usage

package main

import(
	"context"
	dubgo "github.com/dubinc/dub-go"
	"github.com/dubinc/dub-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := dubgo.New(
        dubgo.WithSecurity("DUB_API_KEY"),
    )

    res, err := s.Customers.List(ctx, operations.GetCustomersRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetCustomersRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

[]operations.GetCustomersResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Create

[Deprecated]: Customer creation can only be done via tracking a lead event. Use the /track/lead endpoint instead.

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

package main

import(
	"context"
	dubgo "github.com/dubinc/dub-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := dubgo.New(
        dubgo.WithSecurity("DUB_API_KEY"),
    )

    res, err := s.Customers.Create(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CreateCustomerRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CreateCustomerResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Get

Retrieve a customer by ID for the authenticated workspace.

Example Usage

package main

import(
	"context"
	dubgo "github.com/dubinc/dub-go"
	"github.com/dubinc/dub-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := dubgo.New(
        dubgo.WithSecurity("DUB_API_KEY"),
    )

    res, err := s.Customers.Get(ctx, operations.GetCustomerRequest{
        ID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetCustomerRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.GetCustomerResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Update

Update a customer for the authenticated workspace.

Example Usage

package main

import(
	"context"
	dubgo "github.com/dubinc/dub-go"
	"github.com/dubinc/dub-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := dubgo.New(
        dubgo.WithSecurity("DUB_API_KEY"),
    )

    res, err := s.Customers.Update(ctx, operations.UpdateCustomerRequest{
        ID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.UpdateCustomerRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.UpdateCustomerResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*

Delete

Delete a customer from a workspace.

Example Usage

package main

import(
	"context"
	dubgo "github.com/dubinc/dub-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := dubgo.New(
        dubgo.WithSecurity("DUB_API_KEY"),
    )

    res, err := s.Customers.Delete(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ The unique ID of the customer. You may use either the customer's id on Dub (obtained via /customers endpoint) or their externalId (unique ID within your system, prefixed with ext_, e.g. ext_123).
opts []operations.Option The options for this request.

Response

*operations.DeleteCustomerResponseBody, error

Errors

Error Type Status Code Content Type
sdkerrors.BadRequest 400 application/json
sdkerrors.Unauthorized 401 application/json
sdkerrors.Forbidden 403 application/json
sdkerrors.NotFound 404 application/json
sdkerrors.Conflict 409 application/json
sdkerrors.InviteExpired 410 application/json
sdkerrors.UnprocessableEntity 422 application/json
sdkerrors.RateLimitExceeded 429 application/json
sdkerrors.InternalServerError 500 application/json
sdkerrors.SDKError 4XX, 5XX */*