@unione-repo/javascript-sdk
v1.0.0
Published
UniOne API Client Library for JavaScript
Readme
@unione-repo/javascript-sdk
UniOne - JavaScript client for @unione-repo/javascript-sdk All UniOne API methods require HTTPS connection. UniOne accepts HTTP POST requests in JSON format up to 10 megabytes long and returns HTTP response also in JSON. API endpoint (or base URL) depends on which datacenter the user is registered at.The preferred way is to use https://api.unione.io/en/transactional/api/v1 endpoint, but also you can use https://eu1.unione.io/en/transactional/api/v1 or https://us1.unione.io/en/transactional/api/v1 directly, depending on the host your account was registered at. This SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.76
- Package version: 1.0.0
- Generator version: 7.19.0
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen For more information, please visit https://cp.unione.io/en/support
Installation
For Node.js
npm
Install it via:
npm install @unione-repo/javascript-sdk --saveFinally, you need to build the module:
npm run buildLocal development
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:
npm installNext, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:
npm linkTo use the link you just defined in your project, switch to the directory you want to use your @unione-repo/javascript-sdk from, and run:
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>Finally, you need to build the module:
npm run buildgit
If the library is hosted at a git repository, e.g.https://github.com/unione-repo/javascript-sdk then install it via:
npm install unione-repo/javascript-sdk --saveFor browser
The library also works in the browser environment via npm and browserify. After following
the above steps with Node.js and installing browserify with npm install -g browserify,
perform the following (assuming main.js is your entry file):
browserify main.js > bundle.jsThen include bundle.js in the HTML pages.
Webpack Configuration
Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}Getting Started
Please follow the installation instruction and execute the following JS code:
var UniOne = require('@unione-repo/javascript-sdk');
var defaultClient = UniOne.ApiClient('api.unione.io').instance;
// Configure API key authorization: apiKeyAuth
var apiKeyAuth = defaultClient.authentications['apiKeyAuth'];
apiKeyAuth.apiKey = "YOUR API KEY"
var api = new UniOne.EmailApi()
var bodyObject = new UniOne.BodyObject();
bodyObject.setHtml("<b>Hello, {{to_name}}</b>");
var messageObject = new UniOne.MessageObject();
messageObject.setSubject("UniOne test email");
messageObject.setFromEmail("[email protected]");
messageObject.setRecipients([{"email":"[email protected]","substitutions":{"to_name":"John Smith"},"metadata":{"campaign_id":"c77f4f4e-3561-49f7-9f07-c35be01b4f43"}}])
messageObject.setBody($bodyObject);
var emailSendRequest = new UniOne.EmailSendRequest();
emailSendRequest.setMessage(messageObject);
api.emailSend(emailSendRequest).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
Documentation for API Endpoints
All URIs are relative to https://api.unione.io/en/transactional/api/v1
Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- UniOne.DomainApi | domainDelete | POST /domain/delete.json | Deletes a domain. Attention: you should use project's API key to delete a project's domain. UniOne.DomainApi | domainGetDnsRecords | POST /domain/get-dns-records.json | Returns info on domain DNS setup for using with UniOne. UniOne.DomainApi | domainList | POST /domain/list.json | Returns a list of all registered domains for user or project, together with statuses of last validations. UniOne.DomainApi | domainValidateDkim | POST /domain/validate-dkim.json | Validates DKIM record for domain. UniOne.DomainApi | domainValidateVerificationRecord | POST /domain/validate-verification-record.json | Triggers verification record validation for domain. UniOne.EmailApi | emailSend | POST /email/send.json | Sends an email or a bunch of emails UniOne.EmailApi | emailSubscribe | POST /email/subscribe.json | Sends an email with (re)subscribe link. UniOne.EmailValidationApi | emailValidationSingle | POST /email-validation/single.json | A maximum of two concurrent requests are allowed; if you send more requests, an error will be returned. Since the verification process should be completed promptly, we've set a time limit on email check. If we encounter a slow email server that does not respond in 5 seconds, you may get an “unknown” status. UniOne.EventDumpApi | eventDumpCreate | POST /event-dump/create.json | This asynchronous method initiates the preparation of data dump in CSV format. The number of dump files created or stored is limited to 10; to order more files, you have to delete one of the previous ones or wait until they will be deleted automatically. A newly created dump file is kept for 8 hours. If the request period is more than a day or there are too many events then several files will be generated and each file will contain no more than 100,000 events. File contains columns with the following information - 'event_time', 'job_id', 'from_email', 'email', 'status', 'delivery_status', 'metadata', 'destination_response', 'user_agent', 'url', 'ip', 'tags' and 'project_id' (for accounts with projects enabled). You can change the fields and include 'subject' field using 'dump_fileds' parameter. UniOne.EventDumpApi | eventDumpDelete | POST /event-dump/delete.json | Removes dump from queue or storage. UniOne.EventDumpApi | eventDumpGet | POST /event-dump/get.json | Returns dump properties for a given identifier UniOne.EventDumpApi | eventDumpList | POST /event-dump/list.json | This method does not require any parameters; returns the full list of existing dumps. UniOne.ObsoleteApi | unsubscribedCheck | POST /unsubscribed/check.json | Checks if an email is unsubscribed. UniOne.ObsoleteApi | unsubscribedList | POST /unsubscribed/list.json | Returns a list of all unsubscribed emails since provided date. UniOne.ObsoleteApi | unsubscribedSet | POST /unsubscribed/set.json | Registers a new unsubscribed email. UniOne.ProjectApi | projectCreate | POST /project/create.json | Creates a new project. UniOne.ProjectApi | projectDelete | POST /project/delete.json | Deletes a project. UniOne.ProjectApi | projectList | POST /project/list.json | Lists projects. UniOne.ProjectApi | projectUpdate | POST /project/update.json | Updates a project. UniOne.SuppressionApi | suppressionDelete | POST /suppression/delete.json | Deletes an email from suppression list (only records with is_deletable=true). If there are no entries of this email in the suppression list, API error 3003 is returned. If such entries exist but no one can be deleted, API error 3004 is returned. If daily limit of deletes exceeded, API error 906 is returned. UniOne.SuppressionApi | suppressionGet | POST /suppression/get.json | Gets a reason and date of email suppression. UniOne.SuppressionApi | suppressionList | POST /suppression/list.json | Returns a suppression list since provided date. UniOne.SuppressionApi | suppressionSet | POST /suppression/set.json | Adds an email address to the suppression list. You can always remove this address from the suppression list later using the suppression/delete method. UniOne.SystemApi | systemInfo | POST /system/info.json | Gets user or project info by API key. UniOne.TagApi | tagDelete | POST /tag/delete.json | Removes tag. UniOne.TagApi | tagList | POST /tag/list.json | This method returns the full list of user-defined tags. Does not receive any parameters. UniOne.TemplateApi | templateDelete | POST /template/delete.json | Deletes a template by id. UniOne.TemplateApi | templateGet | POST /template/get.json | Gets template properties by it's id. UniOne.TemplateApi | templateList | POST /template/list.json | Returns the list of all or some templates of the account. UniOne.TemplateApi | templateSet | POST /template/set.json | Creates or updates an email template. UniOne.WebhookApi | webhookDelete | POST /webhook/delete.json | Deletes an event notification handler UniOne.WebhookApi | webhookGet | POST /webhook/get.json | Gets properties of a webhook. UniOne.WebhookApi | webhookList | POST /webhook/list.json | List all or some webhooks (event notification handlers) of a user or a project. UniOne.WebhookApi | webhookSet | POST /webhook/set.json | Sets or edits a webhook, i.e. an event notification handler.
Documentation for Models
- UniOne.AttachmentsArrayInner
- UniOne.BodyObject
- UniOne.BypassComplainedInteger
- UniOne.BypassGlobalInteger
- UniOne.BypassUnavailableInteger
- UniOne.BypassUnsubscribedInteger
- UniOne.DomainDelete200Response
- UniOne.DomainDeleteRequest
- UniOne.DomainGetDnsRecords200Response
- UniOne.DomainGetDnsRecordsRequest
- UniOne.DomainList200Response
- UniOne.DomainList200ResponseDomainsInner
- UniOne.DomainList200ResponseDomainsInnerDkim
- UniOne.DomainList200ResponseDomainsInnerVerificationRecord
- UniOne.DomainListRequest
- UniOne.DomainValidateDkimRequest
- UniOne.DomainValidateVerificationRecord200Response
- UniOne.DomainValidateVerificationRecordRequest
- UniOne.EditorTypeString
- UniOne.EmailSend200Response
- UniOne.EmailSendRequest
- UniOne.EmailSubscribeRequest
- UniOne.EmailValidationSingle200Response
- UniOne.EmailValidationSingleRequest
- UniOne.ErrorResponse
- UniOne.EventDumpCreate200Response
- UniOne.EventDumpCreateRequest
- UniOne.EventDumpDeleteRequest
- UniOne.EventDumpFilesObject
- UniOne.EventDumpGet200Response
- UniOne.EventDumpGetRequest
- UniOne.EventDumpList200Response
- UniOne.EventDumpObject
- UniOne.FilterObject
- UniOne.HeadersObject
- UniOne.InlineAttachmentsArrayInner
- UniOne.MessageObject
- UniOne.MessageObjectOptions
- UniOne.MessageObjectRecipientsInner
- UniOne.ProjectAccountingObject
- UniOne.ProjectCreate200Response
- UniOne.ProjectCreateRequest
- UniOne.ProjectDeleteRequest
- UniOne.ProjectList200Response
- UniOne.ProjectListObject
- UniOne.ProjectListRequest
- UniOne.ProjectObject
- UniOne.ProjectUpdate200Response
- UniOne.ProjectUpdateObject
- UniOne.ProjectUpdateRequest
- UniOne.SuccessResponse
- UniOne.SuccessStatusString
- UniOne.SuppressionDeleteRequest
- UniOne.SuppressionGet200Response
- UniOne.SuppressionGetObject
- UniOne.SuppressionGetRequest
- UniOne.SuppressionList200Response
- UniOne.SuppressionListObject
- UniOne.SuppressionListRequest
- UniOne.SuppressionSetRequest
- UniOne.SystemInfo200Response
- UniOne.SystemInfo200ResponseAccounting
- UniOne.TagDeleteRequest
- UniOne.TagList200Response
- UniOne.TagsResponseObject
- UniOne.TemplateEngineString
- UniOne.TemplateGetRequest
- UniOne.TemplateList200Response
- UniOne.TemplateListObject
- UniOne.TemplateListRequest
- UniOne.TemplateObject
- UniOne.TemplateSet200Response
- UniOne.TemplateSetRequest
- UniOne.TrackLinksInteger
- UniOne.TrackReadInteger
- UniOne.UnsubscribedCheck200Response
- UniOne.UnsubscribedCheckRequest
- UniOne.UnsubscribedList200Response
- UniOne.UnsubscribedList200ResponseUnsubscribedInner
- UniOne.UnsubscribedListRequest
- UniOne.UnsubscribedSet200Response
- UniOne.UnsubscribedSetRequest
- UniOne.WebhookDeliveryInfoInteger
- UniOne.WebhookEventFormatString
- UniOne.WebhookEventsObject
- UniOne.WebhookGetRequest
- UniOne.WebhookList200Response
- UniOne.WebhookListRequest
- UniOne.WebhookObject
- UniOne.WebhookSet200Response
- UniOne.WebhookSetJsonPostRequest
- UniOne.WebhookSetJsonPostRequestEventsByUserInner
- UniOne.WebhookSetJsonPostRequestEventsByUserInnerEventsInner
- UniOne.WebhookSetJsonPostRequestEventsByUserInnerEventsInnerEventData
- UniOne.WebhookSetJsonPostRequestEventsByUserInnerEventsInnerEventDataDeliveryInfo
- UniOne.WebhookSetRequest
- UniOne.WebhookSingleEventInteger
- UniOne.WebhookStatusString
Documentation for Authorization
Authentication schemes defined for the API:
apiKeyAuth
- Type: API key
- API key parameter name: X-API-KEY
- Location: HTTP header
