NDC Elixir SDK

build statusHex.pm

Introduction

This is an Elixir package that wrapps any NDC-compliant API. It's host-agnostic and flexible through-configuration so that it can reach any NDC hosts with flexibility.

Installation

If available in Hex, the package can be installed as:

  1. Add ndc_ex_sdk to your list of dependencies in mix.exs:

    def deps do

     [{:ndc_ex_sdk, "~> 0.0.1"}]

    end

  2. Ensure ndc_ex_sdk is started before your application:

    def application do

     [applications: [:ndc_ex_sdk]]

    end

Use

There are two different ways about how to use this package, all of them using the function NDCEx.request. The common arguments for three interfaces are the next:

  1. NDCEx.request/3 -> request(method, data, path) when is_bitstring(path). Where:

    • path: It is the path to the provider config file. It must to be a string. It shouldn´t contain the name of the config file, only the route to the folder where the file is. Something like: "test/ndc_providers/#{String.upcase(System.get_env("PROVIDER"))}" An example of this first way is the next:

      NDCEx.request(:AirShopping, [AirShoppingRQ:[foo:"bar"]], "path_to/ndc_providers/WA")

  2. NDCEx.request/4 -> request(method, data, config_path, credentials) when is_bitstring(config_path) and is_list(credentials). Where:

    • config_path: is the path to the provider config file. It must to be a string (it can be a data structure if the credentials is nil).
    • credentials: is a list with many possible options. But a mandatory field is consumers, and it must to be a path to the folder where the consumer (per provider) must to be. I mean, that if there is a consumer called "B512", and we have a provider called "WA", we need to make a route like this: "initial_path/ndc_consumers/B512/WA"
      This las way accept that credentials can be nil.
+First example:  

    NDCEx.request(:AirShopping, [AirShoppingRQ:[foo:bar]], "path_to/ndc_providers/WA", nil)

+Second example:  

     NDCEx.request(:AirShopping, [AirShoppingRQ:[foo:bar]], "path_to/ndc_providers/WA", [consumer: "initial_path/ndc_consumers/B512/WA"])