DooxSwitch Reseller API manual

From DooxSwitch wiki
Jump to: navigation, search

Introduction

Application Program Interface (API) that enables our customers to fully integrate our services within real‐time applications, making these processes completely transparent to third parties.


The Reseller Pro API allows software designers to use the functionality provided by this interface to build custom business process applications. This JSON (JavaScript Object Notation) based Web Service connects your customers directly and securely to our VOIP software infrastructure, allowing you to customize the telecommunication services within your own Web architecture. A full set of API commands are available, together with error codes that facilitate simple and accurate programming logic.


API Functions

Authentication Code And Token – You may find your API code in the “Reseller Configuration ‐> Reseller

Settings” section of the website


Registration – new user registration Authorization – log in user for VOIP services use Cabinet

‐ Profile – view user profile

‐ Change password – change user password

‐ Update Balance – add money to user balance

‐ Calls Cost – calls rates

‐ Calls Info – statistics of calls

‐ Trans Info – statistics of transactions


Using API

Each request should be sent to http://195.43.76.39/en/site/api/ You can use the AJAX tools or CURL (to send from PHP).

Sample PHP code (using CURL)

''$url = ‘''[http://195.43.76.39/en/site/api/ 
''$request =''

''‘json={“method”:”userCreate”,”code”:”6855ab4aba98fbca”,”phone”:”380950000000”,”pass”:”superpass”''

''}’;''


''$ch = curl_init();''

''curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request);''

''curl_setopt($ch, CURLOPT_RETURNTRANSFER , TRUE);''

''$page_content = curl_exec($ch);''

''curl_close($ch);''

''echo $page_content;''

$page_content ‐ response in JSON format.


Code
Message
1
Unknown method
2
Format is not supported
3
Missing parameter “login” or “pass”
4
Invalid login or password
5
Token invalid
6
Missing token
7
Missing authentication code
8
Authentication code invalid
9
Invalid password
10 Invalid user phone
11 User phone exists
12 Invalid money value
13 It is not enough money in the account
14 Neither option is not specified
15 Missing phone
16 This phone not assign
17 This position is exists
18 Missing direct phone id
19 Missing type connect
20 Missing filter phone
21 Missing connect phone
22 Missing country name
23 Missing image name
24 Missing background code
25 Missing phone id
26 Missing contact name
27 Missing contact phone
28 Missing phone type
29 You can not add a contact, because there is no free direct numbers

Authentication Code And Token

After you become a Reseller Pro you were sent an email that contains your personal code for

access to our system. You may also find it in the “Reseller Configuration ‐> Reseller Settings” section of the website. This code must be specified in each API request. Use of the code gives you the guarantee that all of your requests will be processed correctly and on time.


Your every user registered in our system through the API must be authenticated using the

username and password entered during registration. After the authorization token will be sent to him. Token and authentication code is a unique pair. A token has time of “life”. After this time, user must again be authorized using a special method of API. After that, user will match the other

token, different from the previous one.


Registration


First of all user must register using API. Upon registration, each user is stored in our database and as‐

signed a unique id.


rpmRegistration


Sample request

'''{“method”:”rpmRegistration”,”code”:”6855ab4aba98fbca”,”phone”:”380950000000”,”pass”:”superpas s”}'''

Parameters:


Name Type Optional
Description
code string
no
Authentication code
phone_number string
no
User phone number (with prefix)
pass string
no
User password

Sample response

'''{“user_id”:516,”pass”:”superpass”,”shotnumber”:531}'''

Parameters:


Name
Type
Description
user_id
int
Unique ID in our system
pass string User password
shotnumber
int
Short number (used for calls via softphones)

Authorization


User needs to authorize before using of API methods. Pay attention that the login is used as a phone number your user entered while registering.


auth


Sample request

'''{“method”:”auth”,”login”:”380950000000”,”pass”:”superpass”,”code”:”6855ab4aba98fbca”}'''

Parameters:


Name
Type Optional
Description
code string
no
Authentication code
login string
no
User login (phone number with prefix)
pass string
no
User password

Sample response

'''{“token”:”9c6f20ea8762de1c1dc6eb5a246e8bbd”,”user_id”:”516”,”expires”:43200}'''

Parameters:


Name
Type
Description
user_id
int
Unique ID in our system
token string Token
expires
int
Token’s time of “life“

Cabinet


There’re several actions in rpmCabinet method which are related to user personal data:


Profile

Sample request

'''{“method”:”rpmCabinet”,”action”:”profile”,”code”:”6855ab4aba98fbca”,”token”:”9c6f20ea8'''

'''762de1c1dc6eb5a246e8bbd”}'''

Parameters:


Name
Type Optional
Value/Description
code string
no
Authentication code
token string
no
Token
action string
no
“profile”

Sample response

'''{“user”:{“email”:”[mailto:[email protected] e][mailto:[email protected] m][mailto:[email protected] ai][mailto:[email protected] l][mailto:[email protected] @do][mailto:[email protected] m][mailto:[email protected] ai][mailto:[email protected] n][mailto:[email protected] .co][mailto:[email protected] m]”,”login”:”380950000000”,”phone”:”'''

'''380950000000”,”money”:”0.00”,”currcoef”:”1”},”currency”:{“1”:{“id”:”1”,”curr_name”:”US Dollar”,”rate”:”1”,”curr_abbreviation”:”USD”}}}'''

Parameters:


User data:


Name
Type
Description
email string User email
login string User login
phone string User phone number
money float User balance
currcoef float Currency exchange coefficient

Currencies array:


Name
Type
Description
id
int
Currency ID in our system
curr_name string Currency name
rate string Currency Exchange rate
curr_abbreviation float 3‐letter currency abbeviation

Change Password

User can change the password to the account.


Sample request

'''{“method”:”rpmCabinet”,”action”:”changepas”,”code”:”6855ab4aba98fbca”,”token”:”9c6f20 ea8762de1c1dc6eb5a246e8bbd”,”passold”:”superpass”,”passnew1”:”newpass”,”passnew2”:'''

'''”newpass”,”save”:true}'''


Parameters:


Name
Type Optional
Description
code string
no
Authentication code
token string
no
Token
action string
no
“changepas”
passold string
no
User old password
passnew1 string
no
User new password
passnew2 string
no
User new password (confirmation)
save bool
no
“true”

Sample response

'''{“status”:”success”}'''

Update Balance

Add money to user balance.


Sample request

'''{“method”:”rpmCabinet”,”action”:”addcost”,”code”:”6855ab4aba98fbca”,”token”:”9c6f20ea'''

'''8762de1c1dc6eb5a246e8bbd”,”money”:”10”}'''

Parameters:


Name
Type Optional
Description
code string
no
Authentication code
token string
no
Token
money
int
no
Amount

Sample response

'''{“money”:”10”,”date”:1333554463}'''

Parameters:


Name
Type
Description
money
int
Entered sum
date
int
Transaction date(server timestamp)

Calls Cost

The cost of calls to directions.


Sample request

'''{“method”:”rpmCabinet”,”action”:”tariffs”,”code”:”6855ab4aba98fbca”,”token”:”9c6f20ea8762de1c1d c6eb5a246e8bbd”,”phone”:”380990000000”}'''

Parameters:


Name
Type Optional
Description
code string
no
Authentication code
token string
no
Token
action string
no
“tariffs”
phone string
yes
Phone number (direction) to display calling tariff for
curr
int
yes
Currency ID in our system

Sample response

'''{“tariffs”:{“prefix_to”:”38099”,”cost_sale”:”0.316”,”direction”:”UKRAINE–MTS”},”currency”:[…],”user_'''

'''curr”:”1”,”countries”:[…],”activeCurr”:”1”}'''


Parameters:


Name
Type
Description
tariffs array Tariff data for requested direction
currency array List of currencies supported by the system
countries array List of countries supported by the system
activeCurr
Int
ID of currently active currency

Calls Info

Calls statistic.


Sample request

'''{“method”:”rpmCabinet”,”action”:”statistics”,”code”:”6855ab4aba98fbca”,”token”:”9c6f20ea8762de1c'''

'''1dc6eb5a246e8bbd”,”min”:”2014‐01‐01”,”max”:”2014‐09‐30”}'''

Parameters:


Name
Type Optional
Description
code string
no
Authentication code
token string
no
Token
action string
no
“statistics”
min string
yes
Date from
max string
yes
Date to

Sample response

'''{“stat”:[{“timecall”:”1234567890000”,”dst”:”380950000010”,”billsec”:”72”,”cost_sale”:”0.314”,”totalc'''


'''ost”:”22.608”}],”filter”:{“date”:{“field_alias”:”timecall”,”min”:”2014‐01‐01”,”max”:”2014‐09‐30”},”field'''

'''_alias”:””,”value”:””},”fields”:[{“name”:”Direction”,”alias”:”dst”},{“name”:”Cost of second”,”alias”:”cost_sale”},{“name”:”Total”,”alias”:”totalcost”}]}'''

Parameters:


Name
Type
Description
stats array List of calls data
filter array Filter data (dates requested)
fields array Fields data

Trans Info

Transactions statistic.


Sample request

'''{“method”:”rpmCabinet”,”action”:”trans”,”code”:”6855ab4aba98fbca”,”token”:”9c6f20ea8762de1c1dc'''

'''6eb5a246e8bbd”,”min”:”2014‐01‐01”,”max”:”2014‐09‐30”}'''


Parameters:


Name
Type Optional
Description
code string
no
Authentication code
token string
no
Token
action string
no
“trans”
min string
yes
Date from
max string
yes
Date to

Sample response

'''{“trans”:[{“time”:”1234567890000”,”paid”:”P”,”sum”:”50”}],”filter”:{“date”:{“field_alias”:”time”,”min”'''

''':”2014‐01‐01”,”max”:”2014‐09‐30”},”field_alias”:””,”value”:””},”fields”:[{“name”:”Sum”,”alias”:”sum”}'''

''',{“name”:”Balance”,”alias”:”balance”}]}'''

Parameters:


Name

Type

Description

trans

array

List of transactions data

filter

array

Filter data (dates requested)

fields

array

Fields data