Coder Social home page Coder Social logo

opm-partners-api's Introduction

OPM Partners API

OPM Partners API allows you to send customer data over a simple and complete REST API.

Authentication

Your requests will be authenticated thanks to a single API key (one per project) that you can request to the OPM Media owners.

Here is an example using the ping endpoint:

fetch('https://api.opdmf.com/ping', {
    headers: {
        'x-api-key': 'REPLACE-WITH-YOUR-KEY'
    }
});

JSON result using a valid API key:

{
    "statusCode": 200,
    "message": "pong"
}

JSON result using an invalid API key:

{
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "API key does not exist"
}

Creating a customer

You can start sending customer data using the entry endpoint, called with the POST method.

fetch('https://api.opdmf.com/entry', {
    method: 'POST',
    headers: {
        'x-api-key': 'REPLACE-WITH-YOUR-KEY'
    },
    body: {
        customerId: 7519,
        customerEmail: '[email protected]',
        customerPhone: '+15853042456',
        customerFirstName: 'John',
        customerLastName: 'Doe',
        customerIP: '192.168.105.240'
    }
});
  • customerId is a required property. This is the internal ID that you uses to identify the customer in your database. It has to be unique, so you can update customer information later using the same ID.
  • customerEmail is a required property, unless a phone number is specified (recommended).
  • customerPhone is a required property, unless an email is specified (recommended).
  • customerFirstName is an optional property (recommended).
  • customerLastName is an optional property (recommended).
  • customerIP is an optional property (recommended).

JSON result using a valid API key:

{
    "statusCode": 201,
    "message": "OK - Created"
}

Updating a customer

Use the same entry endpoint to update customer information, such as the email, phone, last name, first name or IP.

fetch('https://api.opdmf.com/entry', {
    method: 'POST',
    headers: {
        'x-api-key': 'REPLACE-WITH-YOUR-KEY'
    },
    body: {
        customerId: 7519,
        customerEmail: '[email protected]', // update the email
        customerPhone: '+15853042456',
        customerFirstName: 'John',
        customerLastName: 'Doe',
        customerIP: '192.168.105.240'
    }
});

customerId and x-api-key have to be the same you used when creating the customer.

JSON result using a valid API key:

{
    "statusCode": 202,
    "message": "OK - Update accepted"
}

Errors

Requests that do not match the required schemas will result in a 400 error. Some examples:

When skipping required properties:

{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "body must have either required property 'customerEmail' or 'customerPhone'"
}

When using wrong properties type:

{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "body/customerEmail must be string"
}

opm-partners-api's People

Contributors

androz2091 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.