Skip to content

getlago/lago-csharp-client

Repository files navigation

Org.OpenAPITools - the C# library for the Lago API documentation

Lago API allows your application to push customer information and metrics (events) from your application to the billing application.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 0.36.0-beta
  • SDK version: 1.0.0
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Generate the DLL using your preferred tool (e.g. dotnet build)

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://api.getlago.com/api/v1";
            // Configure Bearer token for authorization: bearerAuth
            config.AccessToken = "YOUR_BEARER_TOKEN";

            var apiInstance = new AddOnsApi(config);
            var appliedAddOnInput = new AppliedAddOnInput(); // AppliedAddOnInput | Apply add-on payload

            try
            {
                // Apply an add-on to a customer
                AppliedAddOn result = apiInstance.ApplyAddOn(appliedAddOnInput);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling AddOnsApi.ApplyAddOn: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

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

Class Method HTTP request Description
AddOnsApi ApplyAddOn POST /applied_add_ons Apply an add-on to a customer
AddOnsApi CreateAddOn POST /add_ons Create a new add-on
AddOnsApi DestroyAddOn DELETE /add_ons/{code} Delete an add-on
AddOnsApi FindAddOn GET /add_ons/{code} Find add-on by code
AddOnsApi FindAllAddOns GET /add_ons Find add-ons
AddOnsApi UpdateAddOn PUT /add_ons/{code} Update an existing add-on
BillableMetricsApi CreateBillableMetric POST /billable_metrics Create a new billable metric
BillableMetricsApi DestroyBillableMetric DELETE /billable_metrics/{code} Delete a billable metric
BillableMetricsApi FindAllBillableMetricGroups GET /billable_metrics/{code}/groups Find Billable metric groups
BillableMetricsApi FindAllBillableMetrics GET /billable_metrics Find Billable metrics
BillableMetricsApi FindBillableMetric GET /billable_metrics/{code} Find billable metric by code
BillableMetricsApi UpdateBillableMetric PUT /billable_metrics/{code} Update an existing billable metric
CouponsApi ApplyCoupon POST /applied_coupons Apply a coupon to a customer
CouponsApi CreateCoupon POST /coupons Create a new coupon
CouponsApi DestroyCoupon DELETE /coupons/{code} Delete a coupon
CouponsApi FindAllAppliedCoupons GET /applied_coupons Find Applied Coupons
CouponsApi FindAllCoupons GET /coupons Find Coupons
CouponsApi FindCoupon GET /coupons/{code} Find coupon by code
CouponsApi UpdateCoupon PUT /coupons/{code} Update an existing coupon
CreditNotesApi CreateCreditNote POST /credit_notes Create a new Credit note
CreditNotesApi DownloadCreditNote POST /credit_notes/{id}/download Download an existing credit note
CreditNotesApi FindAllCreditNotes GET /credit_notes Find Credit notes
CreditNotesApi FindCreditNote GET /credit_notes/{id} Find credit note
CreditNotesApi UpdateCreditNote PUT /credit_notes/{id} Update an existing credit note
CreditNotesApi VoidCreditNote PUT /credit_notes/{id}/void Void existing credit note
CustomersApi CreateCustomer POST /customers Create a customer
CustomersApi DeleteAppliedCoupon DELETE /customers/{customer_external_id}/applied_coupons/{applied_coupon_id} Delete customer's appplied coupon
CustomersApi DestroyCustomer DELETE /customers/{external_id} Delete a customer
CustomersApi FindAllCustomers GET /customers Find customers
CustomersApi FindCustomer GET /customers/{external_id} Find customer by external ID
CustomersApi FindCustomerCurrentUsage GET /customers/{customer_external_id}/current_usage Find customer current usage
CustomersApi GetCustomerPortalUrl GET /customers/{customer_external_id}/portal_url Get customer portal URL
EventsApi CreateBatchEvents POST /events/batch Create batch events
EventsApi CreateEvent POST /events Create a new event
EventsApi EventEstimateFees POST /events/estimate_fees Estimate fees for an pay in advance charge
EventsApi FindEvent GET /events/{id} Find event by transaction ID
FeesApi FindAllFees GET /fees Find all fees
FeesApi FindFee GET /fees/{id} Find fee by ID
FeesApi UpdateFee PUT /fees/{id} Update an existing fee
InvoicesApi CreateInvoice POST /invoices Create a new invoice
InvoicesApi DownloadInvoice POST /invoices/{id}/download Download an existing invoice
InvoicesApi FinalizeInvoice PUT /invoices/{id}/finalize Finalize a draft invoice
InvoicesApi FindAllInvoices GET /invoices Find all invoices
InvoicesApi FindInvoice GET /invoices/{id} Find invoice by ID
InvoicesApi RefreshInvoice PUT /invoices/{id}/refresh Refresh a draft invoice
InvoicesApi RetryPayment POST /invoices/{id}/retry_payment Retry invoice payment
InvoicesApi UpdateInvoice PUT /invoices/{id} Update an existing invoice status
OrganizationsApi UpdateOrganization PUT /organizations Update an existing Organization
PlansApi CreatePlan POST /plans Create a new plan
PlansApi DestroyPlan DELETE /plans/{code} Delete a plan
PlansApi FindAllPlans GET /plans Find plans
PlansApi FindPlan GET /plans/{code} Find plan by code
PlansApi UpdatePlan PUT /plans/{code} Update an existing plan
SubscriptionsApi CreateSubscription POST /subscriptions Assign a plan to a customer
SubscriptionsApi DestroySubscription DELETE /subscriptions/{external_id} Terminate a subscription
SubscriptionsApi FindAllSubscriptions GET /subscriptions Find subscriptions
SubscriptionsApi UpdateSubscription PUT /subscriptions/{external_id} Update an existing subscription
WalletsApi CreateWallet POST /wallets Create a new wallet
WalletsApi CreateWalletTransaction POST /wallet_transactions Create a new wallet transaction
WalletsApi DestroyWallet DELETE /wallets/{id} Delete a wallet
WalletsApi FindAllWalletTransactions GET /wallets/{id}/wallet_transactions Find wallet transactions
WalletsApi FindAllWallets GET /wallets Find wallets
WalletsApi FindWallet GET /wallets/{id} Find wallet
WalletsApi UpdateWallet PUT /wallets/{id} Update an existing wallet
WebhooksApi FetchPublicKey GET /webhooks/public_key Fetch webhook public key

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: Bearer Authentication