client.create_licensee
Create
Creates a licensee on a key and returns it with its generated sl_ key. The key must be enabled for sublicensing.
Endpoint
POST /keys/{key}/licensees
See the API reference for this endpoint.
This operation needs a Management Key. Pass it as management_key: to IdealPostcodes::Client.new, which sends it in the Authorization header. See setup.
Signature
def create_licensee(key, name: nil, address: nil, postcode: nil, whitelist: nil, daily: nil)
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
key | String | yes | API Key |
keywords | keyword arguments | no | One per body field, named as the API names them. A keyword left out or nil is not sent. |
Query Parameters
None.
Request Body
Pass these as keyword arguments too; the SDK sends them as the JSON body.
| Name | Type | Required | Description |
|---|---|---|---|
name | String | no | Licensee individual or organisation name |
address | String | no | Licensee's first, second and third line address as well as post town concatenated by commas |
postcode | String | no | Licensee's postcode |
whitelist | Array<String> | no | A list of allowed URLs. An empty list disables the check. |
daily | Hash | no |
Response
IdealPostcodes::Responses::LicenseeResponse. Read fields with readers named as the API names them, such as response.result, or with response["result"]. to_h returns the decoded body.
Errors
An HTTP error raises IdealPostcodes::ApiError with the HTTP status, the API error code and the decoded body. A transport failure raises IdealPostcodes::TransportError. See error handling.
Example
require "ideal_postcodes"
client = IdealPostcodes::Client.new(api_key: "ak_test", management_key: "uk_test")
response = client.create_licensee(
"ak_test",
name: "Acme Ltd",
address: "9 Malyons Road, Swanley",
postcode: "BR8 7RE",
whitelist: ["https://www.acme.example"]
)
puts "Licensee key: #{response.result.key}"