Capital alliance documentation

Partner software system documentation v1.0


Introduction


This documentation is to help you regarding each step of accessing our information. Please go through the documentation carefully to understand how our web service works. Basic JSON and HTTP knowledge is required to simulate or integrate the API

Requirements

You will need the following software or their equivalence to get started.

  1. Code Editing Software (eg: Vs,Code Sublime Text or Notepad)
  2. Api testing tool (eg: Postman or Soap UI)
  3. A language of choice the docs focus on Golang
  4. Knowledge of making request with the API testing tool or your language of choice

To access our partner endpoints, you MUST HAVE CREDENTIALS issued by capital alliance and assigned permissions restricting the endpoints you need

Getting an Api access token #back to top

POSThttps://capitalalliance-kenya.com/api/v1/login

Request Headers

Header Description Value
Accept The Accept request HTTP header advertises which content types, expressed as MIME types, the client is able to understand. application/json

Parameters

The body required to obtain a token with our system is a login email and password registered with capital alliance. In case you are a partner and do not have credentials send a request email to info@capitalalliance-kenya.com

Parameter Description Sample Value
email The partner registered email with capital alliance email@partner.domain
password The partner authentication password with capital alliance system secret

Responses

Sample validation error response
                                            {
                                                "email": [
                                                    "The email field is required."
                                                ],
                                                "password": [
                                                    "The password field is required."
                                                ]
                                            }
                                        
Sample success response

                                            {
                                                "token_type": "Bearer",
                                                "expires_in": 31622400,
                                                "access_token": "PBhC5og6F72Yrg--n7kMB7--4joU6VTKNAZPmXFUeO-KpL436E5tyiGEHx4doY31aEtoAV4mjI",
                                                "refresh_token": "f866567603d2b51ede711863d0f3d756deb08085393"
                                            }

                                        

Getting valuations #back to top

The endpoint can optionally be called without a daterange which returns the valuations in the last 7 days

GEThttps://capitalalliance-kenya.com/api/v1/valuations/partner

GEThttps://capitalalliance-kenya.com/api/v1/valuations/partner?start=19-2-2019&stop=20-2-2019

Request Headers

Header Description Value
Accept The Accept request HTTP header advertises which content types, expressed as MIME types, the client is able to understand. application/json
Authorization The HTTP Authorization request header contains the credentials to authenticate a user agent with a server, usually after the server has responded with a 401 Unauthorized status Bearer access_token

Parameters

The parameters are simply appended to the end poit to pass them with the get request ie ?start=19-2-2019&stop=20-2-2019

Parameter Description Sample Value
start The start of the time range you intend to query. should be an iso date time format 20-2-2019
stop The start of the time range you intend to query. should be an iso date time format d/M/Y

Responses

Validation error responses STATUS 422

Api token does not have access rights for partner valuations


                                    {
                                        "success": false,

                                        "message": "The credentials provided do not give partner access"
                                    }

                                

Provideing just one parameter for date range

                                    {
                                        "stop": [
                                            "The stop field is required when start is present."
                                        ]
                                    }
                                

An invalid format date is provided

                                    {
                                        "success": false,
                                        "message": "stop timestamp given is invalid"
                                    }
                                
Success response STATUS 200 OK
                                    [
                                        {
                                            "client_name": "Tony stark",
                                            "tax": "",
                                            "reg_no": "KPH 448L",
                                            "make_name": "Toyota",
                                            "model_name": "Fielder",
                                            "assessed_value": 950000,
                                            "windscreen": "30000",
                                            "radio_cassete": "Inbuilt",
                                            "date_created": "2019-02-19 09:03:22",
                                            "policy_number": "894/070/1/78954/12/01"
                                        },
                                        {
                                            "client_name": "Black widow",
                                            "tax": "",
                                            "reg_no": "HCN 265V",
                                            "make_name": "Mitsubishi",
                                            "model_name": "Pajero",
                                            "assessed_value": 3100000,
                                            "windscreen": "30000",
                                            "radio_cassete": "Factory Fitted",
                                            "date_created": "2019-02-19 09:14:58",
                                            "policy_number": "456/070/1/799550/78/10"
                                        }
                                    ...
                                    ]
                                

Getting valuation pictures #back to top

The endpoint gives a key value array of the valuation photos links

GEThttps://capitalalliance-kenya.com/api/v1/valuations/{valuation}/pictures

Request Headers

Header Description Value
Accept The Accept request HTTP header advertises which content types, expressed as MIME types, the client is able to understand. application/json
Authorization The HTTP Authorization request header contains the credentials to authenticate a user agent with a server, usually after the server has responded with a 401 Unauthorized status Bearer access_token

Parameters

The parameters are simply appended to the end poit to pass them with the route binding ie {valuation}

Responses

Validation error responses STATUS 422

Api token does not have access rights for partner valuations or the requested valuation does not belong to the particular partner


                                    {
                                        "success": false,

                                        "message": "The credentials provided do not give partner access"
                                    }

                                
Success response STATUS 200 OK
                                    {
                                        "chasispic": "https://capital.sfo2. ... chasispic/26095/1548740233.JPG",
                                        "dashboardpic": "https://capital.sfo2. ... dashboardpic/26095/1548740223.JPG",
                                        "engine_pic": "https://capital.sfo2. ... engine_pic/26095/1548740275.JPG",
                                        "milleage_pic": "https://capital.sfo2. ... milleage_pic/26095/1548740292.JPG",
                                        "front_pic": "https://capital.sfo2. ... front_pic/26095/1548740265.JPG",
                                        "back_pic": "https://capital.sfo2. ... back_pic/26095/1548740241.JPG",
                                        "right_pic": "https://capital.sfo2. ... right_pic/26095/1548740250.JPG",
                                        "left_pic": "https://capital.sfo2. ... left_pic/26095/1548740258.JPG"
                                    }
                                

Examples #back to top

Getting access token in go

                                    const base_url = "https://capitalalliance-kenya.com/api/v1/"

                                    func GetToken(){

                                        formData := url.Values{
                                            "email": {"partner@email.domain"}, "password": {"secret"},
                                        }

                                        client := &http.Client{}
                                        req, err := http.NewRequest("POST", base_url+"login", strings.NewReader(formData.Encode()))
                                        if err != nil {
                                            panic(err.Error())
                                        }

                                        req.Header.Add("Accept", "application/json")
                                        response, err := client.Do(req)
                                        if(err!=nil){
                                            panic(err.Error())
                                        }

                                        /*
                                        From the response retrieve the access token and use it in the valuations request
                                         */
                                    }
                                

Getting valuations in go

                                    const base_url = "https://capitalalliance-kenya.com/api/v1/"

                                    func GetValuations(){

                                        access_token :=GetToken()

                                        client := &http.Client{}
                                        req, err := http.NewRequest("GET", base_url+"valuations/partner",nil)
                                        if err != nil {
                                            panic(err.Error())
                                        }

                                        req.Header.Add("Accept", "application/json")
                                        req.Header.Add("Authorization", "Bearer "+access_token)
                                        response, err := client.Do(req)
                                        if(err!=nil){
                                            panic(err.Error())
                                        }

                                        /*
                                        Iterate through the array returned to save or display data
                                         */

                                    }