stark_bank v1.1.2 StarkBank.Charge.Customer View Source

Used to create, update and delete charge customers

Functions:

  • post
  • get
  • get_by_id
  • delete
  • put

Link to this section Summary

Functions

Deletes the specified charge customers

Gets charge customers data according to informed parameters

Gets the charge customer with the specified ID

Registers new customers that can be linked with charge emissions

Overwrites the charge customer with the specified ID

Link to this section Functions

Link to this function

delete(credentials, customers)

View Source

Deletes the specified charge customers

Parameters:

  • credentials [PID]: agent PID returned by StarkBank.Auth.login;
  • customers [list of strings or list of StarkBank.Charge.Structs.CustomerData (with valid IDs)]: charge customer data or IDs, e.g.: ["6307371336859648"];

Returns {:ok, deleted_customers}:

  • deleted_customers [list of StarkBank.Charge.Structs.CustomerData]: deleted customers;

Example:

iex> StarkBank.Charge.Customer.delete(credentials, ["6307371336859648", "5087311326867881"])

Link to this function

get(credentials, options \\ [])

View Source

Gets charge customers data according to informed parameters

Parameters:

  • credentials [PID]: agent PID returned by StarkBank.Auth.login;
  • options [keyword list]: refines request

    • fields [list of strings]: list of customer fields that should be retrieved from the API;
    • tags [list of strings]: filters customers by the provided tags;
    • tax_id [string]: filters customers by tax ID;
    • limit [int]: maximum results retrieved;

Returns {:ok, retrieved_customers}:

  • retrieved_customers [list of StarkBank.Charge.Structs.CustomerData]: lists all retrieved customers;

Example:

iex> StarkBank.Charge.Customer.get(credentials, fields: ["tax_id", "name"], limit: 30)

Link to this function

get_by_id(credentials, customer)

View Source

Gets the charge customer with the specified ID

Parameters:

  • credentials [PID]: agent PID returned by StarkBank.Auth.login;
  • customer [string or StarkBank.Charge.Structs.CustomerData (with valid ID)]: charge customer ID, e.g.: "6307371336859648";

Returns {:ok, retrieved_customer}:

  • retrieved_customer [StarkBank.Charge.Structs.CustomerData]: retrieved customer;

Example:

iex> StarkBank.Charge.Customer.get_by_id(credentials, "6307371336859648")

iex> StarkBank.Charge.Customer.get_by_id(credentials, customer_1)

Link to this function

post(credentials, customers)

View Source

Registers new customers that can be linked with charge emissions

Parameters:

  • credentials [PID]: agent PID returned by StarkBank.Auth.login;
  • customers: list of StarkBank.Charge.Structs.CustomerData;

Returns {:ok, posted_customers}:

  • posted_customers [list of StarkBank.Charge.Structs.CustomerData]: lists all posted customers;

Example:

iex> StarkBank.Charge.Customer.post(credentials, [customer_1, customer_2])

Link to this function

put(credentials, customer)

View Source

Overwrites the charge customer with the specified ID

Parameters:

  • credentials [PID]: agent PID returned by StarkBank.Auth.login;
  • customer [StarkBank.Charge.Structs.CustomerData]: charge customer data;

Returns {:ok, overwritten_customer}:

  • overwritten_customer [StarkBank.Charge.Structs.CustomerData]: overwritten customer;

Example:

iex> StarkBank.Charge.Customer.put(credentials, customer_1)