1.0.3 • Published 2 years ago

@climes/server-sdk v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Climes Server SDK

Installation

npm install @climes/server-sdk

Documentation

Instantiate the ClimesSdk instance with api_key & environment. For api_key contact Climes Team. environment can be either staging or production

const ClimesSdk = require('@climes/server-sdk');

const instance = new ClimesSdk({
  api_key: 'YOUR_API_KEY',
  environment: 'YOUR_ENVIRONMENT',
});

The resources can be accessed via the instance. All the methods invocations follows the namespaced signature

Basic Truecost Usage

// API signature
// {climesInstance}.{resourceName}.{methodName}({usecase,data})

// example 1
instance.truecost.getTruecost({ 
  usecase : "hotel",
  data : {
    "configs": {
      "total_days": 2,
      "max_occupancy": 3,
      "breakfast": true,
      "washing_machine": true,
      "bedrooms": 2
    }
  }
});

// example 2 (For Calculating truecost for single product)
instance.truecost.getTruecost({ 
  usecase : "calculated",
  data : {
    "configs": {
      "product_id": "7829169307882"
    }
  }
});

// example 2 (For Calculating truecost for multiple products)
instance.truecost.getTruecost({ 
  usecase : "calculated",
  data : {
    "configs": {
      "cart" : [
        {"product_id" : "7829169307882","quantity" : 1},
        {"product_id" : "7829169307882","quantity" : 2}
      ]
    }
  }
});

Basic Orders Usage

// API signature
// {climesInstance}.{resourceName}.{methodName}({usecase,data})

Create Single Order

// example
instance.order.createSingleOrder({ 
  usecase : "calculated",
  data : {
    "order": {
        "climes": 8,
        "partner_order_id": "PAR23987987987897",
        "customer_email" : "johndoe@gmail.com",
        "customer_name": "John Doe",
        "customer_phone" : "+911234567899",
        "unlock_date" : 1654582199000
    }
  }
});

Create Multiple Orders

// example
instance.order.createMultipleOrders({ 
  usecase : "calculated",
  data : {
    "orders": [
      {
        "climes": 8,
        "partner_order_id": "PAR23987987987897",
        "customer_email" : "johndoe@gmail.com",
        "customer_name": "John Doe",
        "customer_phone" : "+911234567899",
        "unlock_date" : 1654582199000
      },
      {
        "climes": 12,
        "partner_order_id": "PAR23987987987897",
        "customer_email" : "markdoe@gmail.com",
        "customer_name": "Mark Doe",
        "customer_phone" : "+912345678911",
        "unlock_date" : 1654572134023
      },
    ]
  }
});

Partial Order Addition

// example
instance.order.partialOrderAddition({ 
  usecase : "calculated",
  data : {
    "climes" : 10,
    "partner_order_id" : "PAR23987987987897"
  }
});

Partial Order Cancellation

// example
instance.order.partialOrderCancellation({ 
  usecase : "calculated",
  data : {
    "climes" : 5,
    "partner_order_id" : "PAR23987987987897"
  }
});

Cancel Order

// example
instance.order.orderCancel({ 
  usecase : "calculated",
  data : {
    "partner_order_id" : "PAR23987987987897"
  }
});
1.0.2

2 years ago

1.0.1

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago