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

Latest commit

 

History

History
583 lines (412 loc) · 15.3 KB

CouponsApi.md

File metadata and controls

583 lines (412 loc) · 15.3 KB

LagoAPI::CouponsApi

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

Method HTTP request Description
apply_coupon POST /applied_coupons Apply a coupon to a customer
create_coupon POST /coupons Create a coupon
delete_applied_coupon DELETE /customers/{external_customer_id}/applied_coupons/{applied_coupon_id} Delete an applied coupon
destroy_coupon DELETE /coupons/{code} Delete a coupon
find_all_applied_coupons GET /applied_coupons List all applied coupons
find_all_coupons GET /coupons List all coupons
find_coupon GET /coupons/{code} Retrieve a coupon
update_coupon PUT /coupons/{code} Update a coupon

apply_coupon

apply_coupon(applied_coupon_input)

Apply a coupon to a customer

This endpoint is used to apply a specific coupon to a customer, before or during a subscription.

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::CouponsApi.new
applied_coupon_input = LagoAPI::AppliedCouponInput.new({applied_coupon: LagoAPI::AppliedCouponInputAppliedCoupon.new({external_customer_id: '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba', coupon_code: 'startup_deal'})}) # AppliedCouponInput | Apply coupon payload

begin
  # Apply a coupon to a customer
  result = api_instance.apply_coupon(applied_coupon_input)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->apply_coupon: #{e}"
end

Using the apply_coupon_with_http_info variant

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

<Array(, Integer, Hash)> apply_coupon_with_http_info(applied_coupon_input)

begin
  # Apply a coupon to a customer
  data, status_code, headers = api_instance.apply_coupon_with_http_info(applied_coupon_input)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <AppliedCoupon>
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->apply_coupon_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
applied_coupon_input AppliedCouponInput Apply coupon payload

Return type

AppliedCoupon

Authorization

bearerAuth

HTTP request headers

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

create_coupon

create_coupon(coupon_create_input)

Create a coupon

This endpoint is used to create a coupon that can be then attached to a customer to create a discount.

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::CouponsApi.new
coupon_create_input = LagoAPI::CouponCreateInput.new({coupon: LagoAPI::CouponCreateInputCoupon.new({name: 'Startup Deal', code: 'startup_deal', coupon_type: 'fixed_amount', frequency: 'once'})}) # CouponCreateInput | Coupon payload

begin
  # Create a coupon
  result = api_instance.create_coupon(coupon_create_input)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->create_coupon: #{e}"
end

Using the create_coupon_with_http_info variant

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

<Array(, Integer, Hash)> create_coupon_with_http_info(coupon_create_input)

begin
  # Create a coupon
  data, status_code, headers = api_instance.create_coupon_with_http_info(coupon_create_input)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Coupon>
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->create_coupon_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
coupon_create_input CouponCreateInput Coupon payload

Return type

Coupon

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::CouponsApi.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 CouponsApi->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 CouponsApi->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_coupon

destroy_coupon(code)

Delete a coupon

This endpoint is used to delete a coupon.

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::CouponsApi.new
code = 'startup_deal' # String | Unique code used to identify the coupon.

begin
  # Delete a coupon
  result = api_instance.destroy_coupon(code)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->destroy_coupon: #{e}"
end

Using the destroy_coupon_with_http_info variant

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

<Array(, Integer, Hash)> destroy_coupon_with_http_info(code)

begin
  # Delete a coupon
  data, status_code, headers = api_instance.destroy_coupon_with_http_info(code)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Coupon>
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->destroy_coupon_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
code String Unique code used to identify the coupon.

Return type

Coupon

Authorization

bearerAuth

HTTP request headers

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

find_all_applied_coupons

find_all_applied_coupons(opts)

List all applied coupons

This endpoint is used to list all applied coupons. You can filter by coupon status and by 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::CouponsApi.new
opts = {
  page: 1, # Integer | Page number.
  per_page: 20, # Integer | Number of records per page.
  status: 'active', # String | The status of the coupon. Can be either `active` or `terminated`.
  external_customer_id: '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba' # String | The customer external unique identifier (provided by your own application)
}

begin
  # List all applied coupons
  result = api_instance.find_all_applied_coupons(opts)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->find_all_applied_coupons: #{e}"
end

Using the find_all_applied_coupons_with_http_info variant

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

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

begin
  # List all applied coupons
  data, status_code, headers = api_instance.find_all_applied_coupons_with_http_info(opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <AppliedCouponsPaginated>
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->find_all_applied_coupons_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
page Integer Page number. [optional]
per_page Integer Number of records per page. [optional]
status String The status of the coupon. Can be either `active` or `terminated`. [optional]
external_customer_id String The customer external unique identifier (provided by your own application) [optional]

Return type

AppliedCouponsPaginated

Authorization

bearerAuth

HTTP request headers

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

find_all_coupons

find_all_coupons(opts)

List all coupons

This endpoint is used to list all existing coupons.

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::CouponsApi.new
opts = {
  page: 1, # Integer | Page number.
  per_page: 20 # Integer | Number of records per page.
}

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

Using the find_all_coupons_with_http_info variant

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

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

begin
  # List all coupons
  data, status_code, headers = api_instance.find_all_coupons_with_http_info(opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CouponsPaginated>
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->find_all_coupons_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

CouponsPaginated

Authorization

bearerAuth

HTTP request headers

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

find_coupon

find_coupon(code)

Retrieve a coupon

This endpoint is used to retrieve a specific coupon.

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::CouponsApi.new
code = 'startup_deal' # String | Unique code used to identify the coupon.

begin
  # Retrieve a coupon
  result = api_instance.find_coupon(code)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->find_coupon: #{e}"
end

Using the find_coupon_with_http_info variant

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

<Array(, Integer, Hash)> find_coupon_with_http_info(code)

begin
  # Retrieve a coupon
  data, status_code, headers = api_instance.find_coupon_with_http_info(code)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Coupon>
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->find_coupon_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
code String Unique code used to identify the coupon.

Return type

Coupon

Authorization

bearerAuth

HTTP request headers

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

update_coupon

update_coupon(code, coupon_update_input)

Update a coupon

This endpoint is used to update a coupon that can be then attached to a customer to create a discount.

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::CouponsApi.new
code = 'startup_deal' # String | Unique code used to identify the coupon.
coupon_update_input = LagoAPI::CouponUpdateInput.new({coupon: LagoAPI::CouponBaseInput.new}) # CouponUpdateInput | Coupon payload

begin
  # Update a coupon
  result = api_instance.update_coupon(code, coupon_update_input)
  p result
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->update_coupon: #{e}"
end

Using the update_coupon_with_http_info variant

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

<Array(, Integer, Hash)> update_coupon_with_http_info(code, coupon_update_input)

begin
  # Update a coupon
  data, status_code, headers = api_instance.update_coupon_with_http_info(code, coupon_update_input)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <Coupon>
rescue LagoAPI::ApiError => e
  puts "Error when calling CouponsApi->update_coupon_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
code String Unique code used to identify the coupon.
coupon_update_input CouponUpdateInput Coupon payload

Return type

Coupon

Authorization

bearerAuth

HTTP request headers

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