0.0.3 • Published 6 years ago

thirdwatch_api v0.0.3

Weekly downloads
2
License
Unlicense
Repository
github
Last release
6 years ago

thirdwatch_api

ThirdwatchApi - JavaScript client for thirdwatch_api

The first version of the Thirdwatch API is an exciting step forward towards making it easier for developers to pass data to Thirdwatch.

Introduction

Once you've registered your website/app it's easy to start sending data to Thirdwatch. All endpoints are only accessible via https and are located at api.thirdwatch.ai. For instance: you can send event at the moment by HTTP POST Request to the following URL with your API key in Header and JSON data in request body.

https://api.thirdwatch.ai/event/v1

Every API request must contain API Key in header value X-THIRDWATCH-API-KEY Every event must contain your _userId (if this is not available, you can alternatively provide a _sessionId value also in _userId).

  • API version: 0.0.1
  • Package version: 0.0.2
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install thirdwatch_api --save
Local 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 install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your thirdwatch_api from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('thirdwatch_api') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/thirdwatch/thirdwatch-nodejs then install it via:

      npm install thirdwatch/thirdwatch-nodejs --save

For 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, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then 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 thirdwatch_api = require('thirdwatch_api');

var defaultClient = thirdwatch_api.ApiClient.instance;

// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['X-THIRDWATCH-API-KEY'] = "Token"

var api = new thirdwatch_api.AddPromotionApi()

var JSON = new thirdwatch_api.AddPromotion(); // {AddPromotion} Pass added promotion info to thirdwatch. Only `_userID` is required field. But this should contain promotion info.


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.addPromotion(JSON, callback);

Documentation for API Endpoints

All URIs are relative to https://api.thirdwatch.ai/event

ClassMethodHTTP requestDescription
thirdwatch_api.AddPromotionApiaddPromotionPOST /v1/add_promotionUse add_promotion to record when a user adds one or more promotions to their account.
thirdwatch_api.AddToCartApiaddToCartPOST /v1/add_to_cartUse add_to_cart when a user adds an item to their shopping cart or list.
thirdwatch_api.ChargebackApichargebackPOST /v1/chargebackUse chargeback to capture a chargeback reported on a transaction. This event can be called multiple times to record changes to the chargeback state.
thirdwatch_api.CreateAccountApicreateAccountPOST /v1/create_accountUse create_account to pass user details at user registration.
thirdwatch_api.CreateOrderApicreateOrderPOST /v1/createOrderSubmit a new or existing order to Thirdwatch for review. This API should contain order item info, the payment info, and user identity info.
thirdwatch_api.CustomEventApicustomEventPOST /v1/custom_eventUse order_status to track the order processing workflow of a previously submitted order.
thirdwatch_api.ItemStatusApiitemStatusPOST /v1/item_statusUse item_status to update the status of item that you’ve already pass to Thirdwatch.
thirdwatch_api.LinkSessionToUserApilinkSessionToUserPOST /v1/link_session_to_userUse link_session_to_user to associate specific session to a user. Generally used only in anonymous checkout workflows.
thirdwatch_api.LoginApiloginPOST /v1/loginUse login to record when a user attempts to log in.
thirdwatch_api.LogoutApilogoutPOST /v1/logoutUse logout to record when a user logs out.
thirdwatch_api.OrderStatusApiorderStatusPOST /v1/order_statusUse order_status to track the order processing workflow of a previously submitted order.
thirdwatch_api.RemoveFromCartApiremoveFromCartPOST /v1/remove_from_cartUse remove_from_cart when a user removes an item from their shopping cart or list.
thirdwatch_api.ReportItemApireportItemPOST /v1/report_itemUse report_item to let us know when another user reports that this item may violate your company’s policies.
thirdwatch_api.SendMessageApisendMessagePOST /v1/send_messageUse send_message to record when a user sends a message to other i.e. seller, support.
thirdwatch_api.SubmitReviewApisubmitReviewPOST /v1/submit_reviewUse submit_review when a user-submitted review of a product or seller.
thirdwatch_api.TagAPIApitagUserPOST /v1/tagThe Tag API enables you to tell Thirdwatch which of your users are bad and which are good.
thirdwatch_api.TransactionApitransactionPOST /v1/transactionUse transaction to record attempts results to Pay, Transfer money, Refund or other transactions.
thirdwatch_api.UntagAPIApiunTagUserPOST /v1/untagIf you are unsure whether a user is bad or good, you can always remove tag and leave the user in a neutral state.
thirdwatch_api.UpdateAccountApiupdateAccountPOST /v1/update_accountUse update_account to record changes to the user's account information.
thirdwatch_api.UpdateOrderApiupdateOrderPOST /v1/update_orderUpdate details of an existing order.

Documentation for Models

Documentation for Authorization

api_key

  • Type: API key
  • API key parameter name: X-THIRDWATCH-API-KEY
  • Location: HTTP header
0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

7 years ago