Packages
ndc_ex_sdk
0.2.30
0.2.30
0.2.29
0.2.27
0.2.26
0.2.25
0.2.24
0.2.23
0.2.22
0.2.21
0.2.20
0.2.19
0.2.18
0.2.17
0.2.16
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.10
0.2.9
0.2.8
0.2.7
0.2.6
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
This is an Elixir package that wrapps any NDC-compliant API. It's host-agnostic and quite flexible-through-configuration so that it can reach NDC hosts with a certain flexibility
Current section
Files
Jump to
Current section
Files
ndc_ex_sdk
README.md
README.md
# NDC Elixir SDK
[](https://gitlab.com/AirGateway/ndc-ex-sdk/commits/master)
[](https://hex.pm/packages/ndc_ex_sdk)
## 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](https://hex.pm/docs/publish), 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:
- *method*: It is the ndc request type, that must to be made (it expect to be an atom).
- *data*: It is the Elixir structure that must to be build into a XML document. It can be merge with many data from the provider or the consumer config.
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"])