Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Latest commit

 

History

History
657 lines (465 loc) · 19 KB

CustomersApi.md

File metadata and controls

657 lines (465 loc) · 19 KB

LagoAPI::CustomersApi

All URIs are relative to https://api.getlago.com/api/v1

Method HTTP request Description
create_customer POST /customers Create a customer
delete_applied_coupon DELETE /customers/{external_customer_id}/applied_coupons/{applied_coupon_id} Delete an applied coupon
destroy_customer DELETE /customers/{external_id} Delete a customer
find_all_customer_past_usage GET /customers/{external_customer_id}/past_usage Retrieve customer past usage
find_all_customers GET /customers List all customers
find_customer GET /customers/{external_id} Retrieve a customer
find_customer_current_usage GET /customers/{external_customer_id}/current_usage Retrieve customer current usage
generate_customer_checkout_url POST /customers/{external_customer_id}/checkout_url Generate a Customer Payment Provider Checkout URL
get_customer_portal_url GET /customers/{external_customer_id}/portal_url Get a customer portal URL

create_customer

create_customer(customer_create_input)

Create a customer

This endpoint creates a new customer.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
customer_create_input = LagoAPI::CustomerCreateInput.new({customer: LagoAPI::CustomerCreateInputCustomer.new({external_id: '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba'})}) # CustomerCreateInput | Customer payload

begin
  # Create a customer
  result = api_instance.create_customer(customer_create_input)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->create_customer: #{e}"
end

Using the create_customer_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> create_customer_with_http_info(customer_create_input)

begin
  # Create a customer
  data, status_code, headers = api_instance.create_customer_with_http_info(customer_create_input)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Customer>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->create_customer_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
customer_create_input CustomerCreateInput Customer payload

Return type

Customer

Authorization

bearerAuth

HTTP request headers

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

delete_applied_coupon

delete_applied_coupon(external_customer_id, applied_coupon_id)

Delete an applied coupon

This endpoint is used to delete a specific coupon that has been applied to a customer.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
external_customer_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | The customer external unique identifier (provided by your own application)
applied_coupon_id = '1a901a90-1a90-1a90-1a90-1a901a901a90' # String | Unique identifier of the applied coupon, created by Lago.

begin
  # Delete an applied coupon
  result = api_instance.delete_applied_coupon(external_customer_id, applied_coupon_id)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->delete_applied_coupon: #{e}"
end

Using the delete_applied_coupon_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> delete_applied_coupon_with_http_info(external_customer_id, applied_coupon_id)

begin
  # Delete an applied coupon
  data, status_code, headers = api_instance.delete_applied_coupon_with_http_info(external_customer_id, applied_coupon_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <AppliedCoupon>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->delete_applied_coupon_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
external_customer_id String The customer external unique identifier (provided by your own application)
applied_coupon_id String Unique identifier of the applied coupon, created by Lago.

Return type

AppliedCoupon

Authorization

bearerAuth

HTTP request headers

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

destroy_customer

destroy_customer(external_id)

Delete a customer

This endpoint deletes an existing customer.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
external_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | External ID of the existing customer

begin
  # Delete a customer
  result = api_instance.destroy_customer(external_id)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->destroy_customer: #{e}"
end

Using the destroy_customer_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> destroy_customer_with_http_info(external_id)

begin
  # Delete a customer
  data, status_code, headers = api_instance.destroy_customer_with_http_info(external_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Customer>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->destroy_customer_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
external_id String External ID of the existing customer

Return type

Customer

Authorization

bearerAuth

HTTP request headers

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

find_all_customer_past_usage

find_all_customer_past_usage(external_customer_id, external_subscription_id, opts)

Retrieve customer past usage

This endpoint enables the retrieval of the usage-based billing data for a customer within past periods.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
external_customer_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | The customer external unique identifier (provided by your own application).
external_subscription_id = 'sub_1234567890' # String | The unique identifier of the subscription within your application.
opts = {
  page: 1, # Integer | Page number.
  per_page: 20, # Integer | Number of records per page.
  billable_metric_code: 'cpu', # String | Billable metric code filter to apply to the charge usage
  periods_count: 5 # Integer | Number of past billing period to returns in the result
}

begin
  # Retrieve customer past usage
  result = api_instance.find_all_customer_past_usage(external_customer_id, external_subscription_id, opts)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_all_customer_past_usage: #{e}"
end

Using the find_all_customer_past_usage_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> find_all_customer_past_usage_with_http_info(external_customer_id, external_subscription_id, opts)

begin
  # Retrieve customer past usage
  data, status_code, headers = api_instance.find_all_customer_past_usage_with_http_info(external_customer_id, external_subscription_id, opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CustomerPastUsage>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_all_customer_past_usage_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
external_customer_id String The customer external unique identifier (provided by your own application).
external_subscription_id String The unique identifier of the subscription within your application.
page Integer Page number. [optional]
per_page Integer Number of records per page. [optional]
billable_metric_code String Billable metric code filter to apply to the charge usage [optional]
periods_count Integer Number of past billing period to returns in the result [optional]

Return type

CustomerPastUsage

Authorization

bearerAuth

HTTP request headers

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

find_all_customers

find_all_customers(opts)

List all customers

This endpoint retrieves all existing customers.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
opts = {
  page: 1, # Integer | Page number.
  per_page: 20 # Integer | Number of records per page.
}

begin
  # List all customers
  result = api_instance.find_all_customers(opts)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_all_customers: #{e}"
end

Using the find_all_customers_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> find_all_customers_with_http_info(opts)

begin
  # List all customers
  data, status_code, headers = api_instance.find_all_customers_with_http_info(opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CustomersPaginated>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_all_customers_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
page Integer Page number. [optional]
per_page Integer Number of records per page. [optional]

Return type

CustomersPaginated

Authorization

bearerAuth

HTTP request headers

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

find_customer

find_customer(external_id)

Retrieve a customer

This endpoint retrieves an existing customer.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
external_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | External ID of the existing customer

begin
  # Retrieve a customer
  result = api_instance.find_customer(external_id)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_customer: #{e}"
end

Using the find_customer_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> find_customer_with_http_info(external_id)

begin
  # Retrieve a customer
  data, status_code, headers = api_instance.find_customer_with_http_info(external_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Customer>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_customer_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
external_id String External ID of the existing customer

Return type

Customer

Authorization

bearerAuth

HTTP request headers

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

find_customer_current_usage

find_customer_current_usage(external_customer_id, external_subscription_id)

Retrieve customer current usage

This endpoint enables the retrieval of the usage-based billing data for a customer within the current period.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
external_customer_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | The customer external unique identifier (provided by your own application).
external_subscription_id = 'sub_1234567890' # String | The unique identifier of the subscription within your application.

begin
  # Retrieve customer current usage
  result = api_instance.find_customer_current_usage(external_customer_id, external_subscription_id)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_customer_current_usage: #{e}"
end

Using the find_customer_current_usage_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> find_customer_current_usage_with_http_info(external_customer_id, external_subscription_id)

begin
  # Retrieve customer current usage
  data, status_code, headers = api_instance.find_customer_current_usage_with_http_info(external_customer_id, external_subscription_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CustomerUsage>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->find_customer_current_usage_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
external_customer_id String The customer external unique identifier (provided by your own application).
external_subscription_id String The unique identifier of the subscription within your application.

Return type

CustomerUsage

Authorization

bearerAuth

HTTP request headers

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

generate_customer_checkout_url

generate_customer_checkout_url(external_customer_id)

Generate a Customer Payment Provider Checkout URL

This endpoint regenerates the Payment Provider Checkout URL of a Customer.

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
external_customer_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | The customer external unique identifier (provided by your own application).

begin
  # Generate a Customer Payment Provider Checkout URL
  result = api_instance.generate_customer_checkout_url(external_customer_id)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->generate_customer_checkout_url: #{e}"
end

Using the generate_customer_checkout_url_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> generate_customer_checkout_url_with_http_info(external_customer_id)

begin
  # Generate a Customer Payment Provider Checkout URL
  data, status_code, headers = api_instance.generate_customer_checkout_url_with_http_info(external_customer_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GenerateCustomerCheckoutURL200Response>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->generate_customer_checkout_url_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
external_customer_id String The customer external unique identifier (provided by your own application).

Return type

GenerateCustomerCheckoutURL200Response

Authorization

bearerAuth

HTTP request headers

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

get_customer_portal_url

get_customer_portal_url(external_customer_id)

Get a customer portal URL

Retrieves an embeddable link for displaying a customer portal. This endpoint allows you to fetch the URL that can be embedded to provide customers access to a dedicated portal

Examples

require 'time'
require 'lago_ruby'
# setup authorization
LagoAPI.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = LagoAPI::CustomersApi.new
external_customer_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | External ID of the existing customer

begin
  # Get a customer portal URL
  result = api_instance.get_customer_portal_url(external_customer_id)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->get_customer_portal_url: #{e}"
end

Using the get_customer_portal_url_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> get_customer_portal_url_with_http_info(external_customer_id)

begin
  # Get a customer portal URL
  data, status_code, headers = api_instance.get_customer_portal_url_with_http_info(external_customer_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GetCustomerPortalUrl200Response>
rescue LagoAPI::ApiError => e
  puts "Error when calling CustomersApi->get_customer_portal_url_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
external_customer_id String External ID of the existing customer

Return type

GetCustomerPortalUrl200Response

Authorization

bearerAuth

HTTP request headers

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