API

Przykład użycia API:

Dodanie nowego klienta:
curl https://api.sugester.pl/app/clients.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"client": {
    "name": "client 1 from API",
    "email": "client1@emailexample1.net",
    "note": "note 1"
  }
}'
Pobranie danych klienta:
curl "https://api.sugester.pl/app/clients/12345.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx"
Aktualizacja danych klienta:
curl https://api.sugester.pl/app/clients/12345.json \
     -X PUT \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"client": {
    "note": "note from API"
  }
}'
Usunięcie klienta:
curl -X DELETE  https://api.sugester.pl/app/clients/12345.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx

Dodanie nowego kontaktu:
curl https://api.sugester.pl/app/contacts.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"contact": {
    "name": "contact 1 from API",
    "email": "contact1@emailexample1.net",
    "note": "note 1",
    "client_id": 12345
  }
}'
Pobranie danych kontaktu:
curl https://api.sugester.pl/app/contacts/12345.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx
Aktualizacja danych kontaktu:
curl https://api.sugester.pl/app/contacts/12345.json \
     -X PUT \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"contact": {
    "note": "note from API"
  }
}'
Usunięcie kontaktu:
curl -X DELETE  https://api.sugester.pl/app/contacts/12345.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx

Pobranie listy zadań:
curl https://api.sugester.pl/app/tasks.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx
Dodanie nowego zadania:
curl https://api.sugester.pl/app/posts.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"post": {
    "title":"task title 1 from API",
    "content": "task content 1",
    "task_kind": "task",
    "client_id": null,
    "responsible_id": 1
  }
}'
Dodanie nowego dealu:
curl https://api.sugester.pl/app/deals.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"deal": {
    "name": "deal 1 from API",
    "description": "desc 1",
    "client_id": null
  }
}'
Dodanie nowego konta:
curl https://api.sugester.pl/app/account.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"account": {
    "prefix":"xxxxxxxx",
    "initial_module": "crm",
    "from_partner": "partner1"
 },
"user": {
    "login": "login1",
    "email": "email1@sugester-email.pl",
    "password": "password1"
 }
}'

Integracje

Dodanie nowego klienta:
curl https://api.sugester.pl/app/clients.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"client": {
    "name": "client 2 from External APP via API",
    "email": "c2@emailexample.net",
    "note": "note ext 2",
    "external_ids": {
        "myapp_client_id": "17"
    }
  }
}'
Dodanie nowego dealu:
curl https://api.sugester.pl/app/deals.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"deal": {
    "name": "deal 2 from External APP via API",
    "description": "desc 2",
    "price": 117,
    "client": {
        "name": "client 2 from External APP via API",
        "email": "c2@emailexample.net",
        "external_ids": {
            "myapp_client_id": "17"
        }
    },
    "external_ids": {
        "myapp_invoice_id": "21"
    }
  }
}'
Lista odbiorców

Dodanie
curl https://api.sugester.pl/app/contact_lists.json \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"contact_list": {
    "name": "New contact list"
  }
}'
Pobranie danych:
curl https://api.sugester.pl/app/contact_lists/10.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx
Aktualizacja
curl https://api.sugester.pl/app/contact_lists/10.json \
     -X PUT \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"contact_list": {
    "name": "New contact list updated"
  }
}'
Aktualizacja danych kontaktu
curl https://api.sugester.pl/app/contacts/12345.json \
     -X PUT \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '
{
"api_token": "xxxxxxxxxxxxxxxx/xxxxxxx",
"contact": {
    "contact_list_ids": [10, 19]
  }
}'
Pobieranie listy tagów dla klientów
curl https://api.sugester.pl/app/clients/tags.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx
Pobieranie listy tagów dla postów
curl https://api.sugester.pl/app/posts/tags.json?api_token=xxxxxxxxxxxxxxxx%2Fxxxxxxx

Link do API na GitHubie