NAV
coffee

Introduction

This is the documentation of the API used on the platform all for Body

(web) Accounting

This section contains API to negotiate price lists between coach and client.

Get default price list

This is used to obtain the default price list when new price list is created. It either returns default prices or the price list last used by coach.

To obtain the default price list, perform:

$.ajax
  dataType: "json"
  type: "get"
  data:
  url: "http://users.allforbody.pl/accounting/default_price_list.json"
  success: (data, status, jqXHR) ->
    processSomehow(data)

The above command returns JSON structured like this:

{
    default_prices:
    {
        calendar_task: 5.0
        calendar_note: 2.0
        calendar_comment: 1.0
        client_wall_message: 2.0
        api_sms_message: 2.0
        currency: NOK
    }
    commission: 20
    available_currencies: [PLN, USD, NOK]
    estimated_amounts: {
        knowledge: 20
        motivaiton: 30
    }
}

HTTP Request

GET http://users.allforbody.pl/accounting/default_price_list.json

Get price list for support

This is used to obtain the price list for the given support, ie. for a given coach-client relation.

To obtain the default price list, perform:

$.ajax
  dataType: "json"
  type: "get"
  data:
    support_id: 8
  url: "http://users.allforbody.pl/accounting/support_price_list.json"
  success: (data, status, jqXHR) ->
    processSomehow(data)

The above command returns JSON structured like this:

{
    id: 12
    calendar_task: 5.0
    calendar_note: 2.0
    calendar_comment: 1.0
    client_wall_message: 2.0
    api_sms_message: 2.0
    currency: PLN
    commission: 20
    accepted_at: <<timestamp>>
    rejected_at: nil,
    estimated_amounts: {
        knowledge: 20,
        motivation: 30
    }

}

HTTP Request

GET http://users.allforbody.pl/accounting/support_price_list.json

Create price list

It allows for creating price list for support. Custom message can be passed as :message. The welcome (true/false) decides on the email styling.

To create a new price list, perform: coffee $.ajax dataType: "json" type: "post" data: support_id: 2 prices: calendar_task: 2, calendar_note: 2, calendar_comment: 2, client_wall_message: 2, api_sms_message: 2 welcome: true message: "Witaj, będzie się nam fajnie trenowało, yno pierwyj kasa" estimated_amounts: knowledge: 20 motivation: 30 url: "http://users.allforbody.pl/accounting/price_lists" success: (data, status, jqXHR) -> processSomehow(data)

HTTP Request

POST http://users.allforbody.pl/accounting/price_lists

Response codes

Code Description
201 Successfully created.

Query Parameters

Price lists can be of 2 types: depending on the number of services (i.e. standard) or constant amount of money per month (i.e. fixed)

Standard price lists

Parameter Default Description
support_id null Id of the support between coach and client.
prices/calendar_task null
prices/calendar_note null
prices/calendar_comment null
prices/client_wall_message null
prices/api_sms_message null

Fixed price lists

Parameter Default Description
support_id null Id of the support between coach and client.
fixed_price null The amount in users currency, eg. 125.0

(web) Clients

Accepting the regulations

This API provides a call to mark regulations as accepted.

To accept regulations for (authenticated previously) user (client) of ID 5:

$.ajax
  dataType: "json"
  type: "put"
  data:
  url: "http://users.allforbody.pl/clients/5/accept_regulations"
  success: (data, status, jqXHR) ->
    processSomehow(data)

To accept regulations for (authenticated previously) coach of ID 5:

$.ajax
  dataType: "json"
  type: "put"
  data:
    role: 'coach'
  url: "http://users.allforbody.pl/clients/5/accept_regulations"
  success: (data, status, jqXHR) ->
    processSomehow(data)

HTTP Request

PUT http://users.allforbody.pl/clients/:ID/accept_regulations

Query Parameters

Parameter Default Description
role “client” The role for which the regulations are accepted.

Response codes

Code Description
200 Regulations accepted.
401 User role does not exist (see errors key in json).

Errors

The Kittn API uses the following error codes:

Error Code Meaning
400 Bad Request – Your request sucks
401 Unauthorized – Your API key is wrong
403 Forbidden – The kitten requested is hidden for administrators only
404 Not Found – The specified kitten could not be found
405 Method Not Allowed – You tried to access a kitten with an invalid method
406 Not Acceptable – You requested a format that isn’t json
410 Gone – The kitten requested has been removed from our servers
418 I’m a teapot
429 Too Many Requests – You’re requesting too many kittens! Slown down!
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarially offline for maintanance. Please try again later.