Skip to content

hopper/hts-airlines-dotnet

Repository files navigation

Com.Hopper.Hts.Airlines - the C# library for the Airline API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

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

  • API version: v1.1
  • SDK version: 0.1.4
  • Generator version: 7.10.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen

Frameworks supported

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

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

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

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

using Com.Hopper.Hts.Airlines.Api;
using Com.Hopper.Hts.Airlines.Client;
using Com.Hopper.Hts.Airlines.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out Com.Hopper.Hts.Airlines.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

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 Com.Hopper.Hts.Airlines.Api;
using Com.Hopper.Hts.Airlines.Client;
using Com.Hopper.Hts.Airlines.Model;

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

            Configuration config = new Configuration();
            config.BasePath = "https://airlines-api.hopper.com/airline/v1.1";
            // Configure API key authorization: SessionAuth
            config.ApiKey.Add("HC-Session-ID", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.ApiKeyPrefix.Add("HC-Session-ID", "Bearer");

            var apiInstance = new AnalyticsApi(config);
            var cfarEvent = new CfarEvent(); // CfarEvent | 

            try
            {
                // Send a Frontend Event
                apiInstance.PostCustomerEvents(cfarEvent);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling AnalyticsApi.PostCustomerEvents: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://airlines-api.hopper.com/airline/v1.1

Class Method HTTP request Description
AnalyticsApi PostCustomerEvents POST /customer/events Send a Frontend Event
AnalyticsApi PostEvents POST /events Send a Backend Event
AuthenticationApi PostAuth POST /auth Create an authentication token
CancelForAnyReasonCFARApi GetCfarContractsId GET /cfar_contracts/{id} Get a CFAR Contract
CancelForAnyReasonCFARApi PostCfarContractExercises POST /cfar_contract_exercises Create CFAR Exercise
CancelForAnyReasonCFARApi PostCfarContracts POST /cfar_contracts Create a CFAR Contract
CancelForAnyReasonCFARApi PostCfarContractsIdPayment POST /cfar_contracts/{id}/payment Process CFAR Payment
CancelForAnyReasonCFARApi PostCfarOffers POST /cfar_offers Create CFAR Offers
CancelForAnyReasonCFARApi PutCfarContractExercisesIdMarkCompleted PUT /cfar_contract_exercises/{id}/mark_completed Complete CFAR Exercise
CancelForAnyReasonCFARApi PutCfarContractsIdFormsOfPayment PUT /cfar_contracts/{id}/forms_of_payment Update forms of payment of a CFAR Contract
CancelForAnyReasonCFARApi PutCfarContractsIdUpdateStatus PUT /cfar_contracts/{id}/update_status Update CFAR Contract Status
DisruptionGuaranteeDGApi GetDgContractsId GET /dg_contracts/{id} Get a DG contract
DisruptionGuaranteeDGApi PostCustomerDgEvents POST /customer/dg/events Create an Event
DisruptionGuaranteeDGApi PostDgContractExercises POST /dg_contract_exercises Create DG Exercise
DisruptionGuaranteeDGApi PostDgContracts POST /dg_contracts Create a DG Contract
DisruptionGuaranteeDGApi PostDgContractsIdPayment POST /dg_contracts/{id}/payment Process DG payment
DisruptionGuaranteeDGApi PostDgOffers POST /dg_offers Create DG Offers
DisruptionGuaranteeDGApi PutDgContractsIdItinerarySlices PUT /dg_contracts/{id}/itinerary_slices Update DG Contract Itinerary Slices
DisruptionGuaranteeDGApi PutDgContractsIdUpdateStatus PUT /dg_contracts/{id}/update_status Update DG Contract Status
SessionsApi PostSessions POST /sessions Create a Session

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

PartnerAuth

  • Type: Bearer Authentication

SessionAuth

  • Type: API key
  • API key parameter name: HC-Session-ID
  • Location: HTTP header

Development

You can regenerate the client using this command:

VERSION=0.1.2 docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
    -i https://airlines-api.hopper.com/airline/v1.1/docs/docs.yaml \
    -g csharp \
    -o /local \
    --package-name Com.Hopper.Hts.Airlines \
    --additional-properties=optionalEmitDefaultValues=true,nullableReferenceTypes=true,validatable=false,licenseId=MIT,packageVersion=$VERSION

Please be mindful of the README.md getting overwritten. Please manually restore these instructions before committing.

Publishing

Create the package

dotnet pack src/Com.Hopper.Hts.Airlines

Example run:

➜  htsfa-airlines-dotnet git:(main) dotnet pack src/Com.Hopper.Hts.Airlines
  Determining projects to restore...
  Restored /Users/llaw/Documents/Github/htsfa-airlines-dotnet/src/Com.Hopper.Hts.Airlines/Com.Hopper.Hts.Airlines.csproj (in 506 ms).
/Users/llaw/Documents/Github/htsfa-airlines-dotnet/src/Com.Hopper.Hts.Airlines/Client/ApiClient.cs(457,17): warning CS0618: 'RestClientOptions.MaxTimeout' is obsolete: 'Use Timeout instead.' [/Users/llaw/Documents/Github/htsfa-airlines-dotnet/src/Com.Hopper.Hts.Airlines/Com.Hopper.Hts.Airlines.csproj]
  Com.Hopper.Hts.Airlines -> /Users/llaw/Documents/Github/htsfa-airlines-dotnet/src/Com.Hopper.Hts.Airlines/bin/Release/net8.0/Com.Hopper.Hts.Airlines.dll
  The package Com.Hopper.Hts.Airlines.0.1.2 is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important.
  Successfully created package '/Users/llaw/Documents/Github/htsfa-airlines-dotnet/src/Com.Hopper.Hts.Airlines/bin/Release/Com.Hopper.Hts.Airlines.0.1.2.nupkg'.

Go to NuGet and upload the package artifact created. In the example above, it is Com.Hopper.Hts.Airlines.0.1.2.nupkg. After submission, the package will be ready for consumption usually within 10-15 minutes.

You will need to obtain an Azure account to access NuGet. Contact IT to do so.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published