REST API
Poniżej przedstawiam przykładowe zapytania i odpowiedzi
Endpoint-y nie wymagające autoryzacji:
POST: api/login (logowanie)
Array ( [email] => test@email.com [password] => cmsrs )
stdClass Object ( [success] => 1 [data] => stdClass Object ( [token] => eyJ0eXAiOiJK...7nhyflrqY-xA ) )
POST: api/comments/$pageId (utworzenie komentarza)
Array ( [content] => test comment - test123 )
stdClass Object ( [success] => 1 )
GET: api/comments/$pageId (zwracamy komentarze)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [content] => 111 test comment - test123 ) [1] => stdClass Object ( [content] => 222 test comment - test123 ) ) )
POST: api/contact/$lang (utworzenie wiadomości kontaktowej)
Array ( [email] => test@example.com [message] => test message - test123 )
stdClass Object ( [success] => 1 [message] => Dziękuje za skorzystanie z formularza kontaktowego )
GET: api/page/$pageId/$lang (zwracamy stronę)
stdClass Object ( [success] => 1 [data] => stdClass Object ( [id] => 1 [type] => cms [images] => Array ( [0] => stdClass Object ( [org] => /images/page/1/1/phpunittest1.jpg [small] => /images/page/1/1/phpunittest1-small.jpg [medium] => /images/page/1/1/phpunittest1-medium.jpg [id] => 1 [alt] => stdClass Object ( [en] => description img1 ) [altlang] => description img1 ) [1] => stdClass Object ( [org] => /images/page/1/2/phpunittest2.jpg [small] => /images/page/1/2/phpunittest2-small.jpg [medium] => /images/page/1/2/phpunittest2-medium.jpg [id] => 2 [alt] => stdClass Object ( [en] => ) [altlang] => ) ) ) )
Endpoint-y wymagające autoryzacji:
GET: api/logout?token=$token (wylogowanie)
stdClass Object ( [success] => 1 [message] => You have successfully logged out. )
POST: api/pages?token=$token (utworzenie strony)
Array ( [title] => Array ( [en] => test p2 ) [short_title] => Array ( [en] => p22 ) [description] => Array ( [en] => test1234 ) [published] => 0 [commented] => 0 [after_login] => 0 [type] => contact [content] => Array ( [en] => lorem ipsum ) [menu_id] => [page_id] => [images] => Array ( [0] => Array ( [name] => phpunittest1.jpg [data] => data:image/jpg;base64,/9j/4AAQSkZ..rAFS6G7Jr1PeP/9k= [alt] => Array ( [en] => description img1 ) ) [1] => Array ( [name] => phpunittest2.jpg [data] => data:image/jpg;base64,/9j/4AAQSkZJRg...wRV82DVqaZSCAev/Z ) ) )
stdClass Object ( [success] => 1 [data] => stdClass Object ( [pageId] => 1 [data] => stdClass Object ( [title] => stdClass Object ( [en] => test p2 ) [short_title] => stdClass Object ( [en] => p22 ) [description] => stdClass Object ( [en] => test1234 ) [published] => 0 [commented] => 0 [after_login] => 0 [type] => contact [content] => stdClass Object ( [en] => lorem ipsum ) [menu_id] => [page_id] => [images] => Array ( [0] => stdClass Object ( [name] => phpunittest1.jpg [data] => data:image/jpg;base64,/9j/4AA....WTrAFS6G7Jr1PeP/9k= [alt] => stdClass Object ( [en] => description img1 ) ) [1] => stdClass Object ( [name] => phpunittest2.jpg [data] => data:image/jpg;base64,/9j/4A...DVqaZSCAev/Z ) ) ) ) )
GET: api/pages?token=$token (pobieramy strony)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [id] => 1 [published] => 0 [commented] => 0 [after_login] => 0 [position] => 1 [type] => contact [menu_id] => [page_id] => [title] => stdClass Object ( [en] => test p2 ) [short_title] => stdClass Object ( [en] => p22 ) [description] => stdClass Object ( [en] => test1234 ) [content] => stdClass Object ( [en] => lorem ipsum ) [images] => Array ( [0] => stdClass Object ( [id] => 1 [name] => phpunittest1.jpg [position] => 1 [page_id] => 1 [product_id] => [created_at] => 2020-11-20T15:38:20.000000Z [updated_at] => 2020-11-20T15:38:20.000000Z [alt] => stdClass Object ( [en] => description img1 ) [fs] => stdClass Object ( [org] => /images/page/1/1/phpunittest1.jpg [small] => /images/page/1/1/phpunittest1-small.jpg [medium] => /images/page/1/1/phpunittest1-medium.jpg ) ) [1] => stdClass Object ( [id] => 2 [name] => phpunittest2.jpg [position] => 2 [page_id] => 1 [product_id] => [created_at] => 2020-11-20T15:38:20.000000Z [updated_at] => 2020-11-20T15:38:20.000000Z [alt] => stdClass Object ( [en] => ) [fs] => stdClass Object ( [org] => /images/page/1/2/phpunittest2.jpg [small] => /images/page/1/2/phpunittest2-small.jpg [medium] => /images/page/1/2/phpunittest2-medium.jpg ) ) ) ) ) )
GET: api/pages/$pageId?token=$token (pobieramy strone o danym Id)
stdClass Object ( [success] => 1 [data] => stdClass Object ( [id] => 1 [published] => 1 [commented] => 1 [after_login] => 0 [position] => 1 [type] => cms [menu_id] => [page_id] => [title] => stdClass Object ( [en] => page 1 test ) [short_title] => stdClass Object ( [en] => page1 ) [description] => stdClass Object ( [en] => this page: test desc ... ) [content] => stdClass Object ( [en] => content test133445 ) [images] => Array ( ) ) )
PUT: api/pages/$id?token=$token (uaktualniamy stronę)
Array ( [title] => Array ( [en] => Update img Title ) [short_title] => Array ( [en] => test123 ) [images] => Array ( [0] => Array ( [id] => 1 [alt] => Array ( [en] => alt1 ) ) [1] => Array ( [id] => 2 [alt] => Array ( [en] => alt2 ) ) [2] => Array ( [name] => phpunittest2.jpg [data] => data:image/jpg;base64,/9j/4A...V82DVqaZSCAev/Z ) [3] => Array ( [name] => phpunittest2.jpg [data] => data:image/jpg;base64,/9j/4AA...xuwRV82DVqaZSCAev/Z ) ) )
stdClass Object ( [success] => 1 )
DELETE: api/pages/$id?token=$token (kasujemy stronę)
stdClass Object ( [success] => 1 )
GET: api/pages/position/$direction/$id?token=$token (ustawiamy pozycję strony, gdzie $direction: up, down)
stdClass Object ( [success] => 1 )
GET: api/pages/type/$type (zwróć strony na podstawie typu, gdzie $type: cms, gallery, shop, contact, main_page, privacy_policy, login, projects)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [id] => 1 [published] => 0 [commented] => 0 [after_login] => 0 [position] => 1 [type] => shop [menu_id] => [page_id] => [title] => stdClass Object ( [en] => test p2 ) [short_title] => stdClass Object ( [en] => p22 ) [description] => stdClass Object ( [en] => ) [content] => stdClass Object ( [en] => aaa ffdfds ) [images] => Array ( ) ) ) )
GET: api/images/$type/$pageId?token=$token (zwracamy obrazki, gdzie type: page, product)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [id] => 1 [name] => phpunittest1.jpg [position] => 1 [page_id] => 1 [product_id] => [created_at] => 2020-11-22T16:38:46.000000Z [updated_at] => 2020-11-22T16:38:46.000000Z [alt] => stdClass Object ( [en] => description img1 ) [fs] => stdClass Object ( [org] => /images/page/1/1/phpunittest1.jpg [small] => /images/page/1/1/phpunittest1-small.jpg [medium] => /images/page/1/1/phpunittest1-medium.jpg ) ) [1] => stdClass Object ( [id] => 2 [name] => phpunittest2.jpg [position] => 2 [page_id] => 1 [product_id] => [created_at] => 2020-11-22T16:38:46.000000Z [updated_at] => 2020-11-22T16:38:46.000000Z [alt] => stdClass Object ( [en] => ) [fs] => stdClass Object ( [org] => /images/page/1/2/phpunittest2.jpg [small] => /images/page/1/2/phpunittest2-small.jpg [medium] => /images/page/1/2/phpunittest2-medium.jpg ) ) ) )
GET: api/images/position/$direction/$id?token=$token (ustawiamy pozycję obrazka)
stdClass Object ( [success] => 1 )
DELETE: api/images/$id?token=$token (kasujemy obrazek)
stdClass Object ( [success] => 1 )
GET: api/users/clients?token=$token (zwracamy klientów)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [id] => 3 [name] => Robert Test [email] => rob@unittest.com [created_at] => 2020-11-22T16:52:28.000000Z [updated_at] => 2020-11-22T16:52:28.000000Z ) ) )
POST: api/products?token=$token (tworzymy produkt)
Array ( [product_name] => Array ( [en] => php3 db app ) [sku] => AN/34534 [price] => 123 [product_description] => Array ( [en] => book desc ) [page_id] => 1 [images] => Array ( [0] => Array ( [name] => phpunittest1.jpg [data] => data:image/jpg;base64,/9j/4A.....AFS6G7Jr1PeP/9k= [alt] => Array ( [en] => description img1 - product image ) ) [1] => Array ( [name] => phpunittest2.jpg [data] => data:image/jpg;base64,/9j/4AAQSkZ....qaZSCAev/Z ) ) )
stdClass Object ( [success] => 1 [data] => stdClass Object ( [productId] => 1 [data] => stdClass Object ( [product_name] => stdClass Object ( [en] => php3 db app ) [sku] => AN/34534 [price] => 123 [product_description] => stdClass Object ( [en] => book desc ) [page_id] => 1 [images] => Array ( [0] => stdClass Object ( [name] => phpunittest1.jpg [data] => data:image/jpg;base64,/9j/4AAQSkZJ....rAFS6G7Jr1PeP/9k= [alt] => stdClass Object ( [en] => description img1 - product image ) ) [1] => stdClass Object ( [name] => phpunittest2.jpg [data] => data:image/jpg;base64,/9j/4AAQSkZJRg....82DVqaZSCAev/Z ) ) ) ) )
GET: api/products?token=$token (zwracamy produkty)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [id] => 1 [sku] => AN/34534 [price] => 123 [page_id] => 1 [product_name] => stdClass Object ( [en] => php3 db app ) [product_description] => stdClass Object ( [en] => book desc ) [product_name_default_lang] => php3 db app [images] => Array ( [0] => stdClass Object ( [id] => 1 [name] => phpunittest1.jpg [position] => 1 [page_id] => [product_id] => 1 [created_at] => 2021-01-20T21:21:36.000000Z [updated_at] => 2021-01-20T21:21:36.000000Z [alt] => stdClass Object ( [en] => description img1 - product image ) [fs] => stdClass Object ( [org] => /images/product/1/1/phpunittest1.jpg [small] => /images/product/1/1/phpunittest1-small.jpg [medium] => /images/product/1/1/phpunittest1-medium.jpg ) ) [1] => stdClass Object ( [id] => 2 [name] => phpunittest2.jpg [position] => 2 [page_id] => [product_id] => 1 [created_at] => 2021-01-20T21:21:36.000000Z [updated_at] => 2021-01-20T21:21:36.000000Z [alt] => stdClass Object ( [en] => ) [fs] => stdClass Object ( [org] => /images/product/1/2/phpunittest2.jpg [small] => /images/product/1/2/phpunittest2-small.jpg [medium] => /images/product/1/2/phpunittest2-medium.jpg ) ) ) ) ) )
PUT: api/products/$id?token=$token (aktualizujemy produkt)
Array ( [product_name] => Array ( [en] => PHP7 ) [sku] => AN/34534 [price] => 123 [product_description] => Array ( [en] => PHP7 - desc ) [page_id] => 1 [images] => Array ( [0] => Array ( [id] => 1 [name] => phpunittest1.jpg [position] => 1 [page_id] => [product_id] => 1 [created_at] => 2021-01-20T21:31:20.000000Z [updated_at] => 2021-01-20T21:31:20.000000Z [alt] => Array ( [en] => alt1 ) [fs] => stdClass Object ( [org] => /images/product/1/1/phpunittest1.jpg [small] => /images/product/1/1/phpunittest1-small.jpg [medium] => /images/product/1/1/phpunittest1-medium.jpg ) ) [1] => Array ( [id] => 2 [name] => phpunittest2.jpg [position] => 2 [page_id] => [product_id] => 1 [created_at] => 2021-01-20T21:31:20.000000Z [updated_at] => 2021-01-20T21:31:20.000000Z [alt] => Array ( [en] => alt2 ) [fs] => stdClass Object ( [org] => /images/product/1/2/phpunittest2.jpg [small] => /images/product/1/2/phpunittest2-small.jpg [medium] => /images/product/1/2/phpunittest2-medium.jpg ) ) [2] => Array ( [name] => phpunittest2.jpg [data] => data:image/jpg;base64,/9j/4AAQSkZJRgA...VqaZSCAev/Z ) ) )
stdClass Object ( [success] => 1 )
DELETE: api/products/$id?token=$token (kasujemy produkt)
stdClass Object ( [success] => 1 )
GET: api/contacts?token=$token (pobieramy wiadomości kontaktowe)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [id] => 1 [email] => test@example.com [message] => test message - test1 [created_at_format] => 2020-11-23 15:40:14 ) [1] => stdClass Object ( [id] => 2 [email] => ja@cmsrs.pl [message] => test2 [created_at_format] => 2020-11-23 15:40:14 ) ) )
DELETE: api/contacts/$id?token=$token (kasujemy wiadomość kontaktową)
stdClass Object ( [success] => 1 )
GET: api/config?token=$token (pobieramy wartości konfiguracyjne)
stdClass Object ( [success] => 1 [data] => stdClass Object ( [page_types] => Array ( [0] => cms [1] => gallery [2] => shop [3] => contact [4] => main_page [5] => privacy_policy ) [langs] => Array ( [0] => en ) [cache_enable] => 1 ) )
GET: api/checkouts?token=$token ( pobieramy złożone zamówienia z zawartością koszyka)
stdClass Object ( [success] => 1 [data] => Array ( [0] => stdClass Object ( [id] => 1 [price_total] => 1829 [price_deliver] => 14 [price_total_add_deliver] => 1843 [user_id] => 1 [email] => client@cmsrs.pl [first_name] => Jan [last_name] => Kowalski [address] => kolejowa 1 m 2 [country] => Polska [city] => Warszawa [telephone] => 1234567123 [postcode] => 03-456 [is_pay] => 0 [created_at] => 2021-06-18T16:20:05.000000Z [baskets] => Array ( [0] => stdClass Object ( [qty] => 2 [price] => 112 [product_id] => 1 [product_name] => name11 [product_url] => /cms/books/programmer/name11 ) [1] => stdClass Object ( [qty] => 5 [price] => 321 [product_id] => 2 [product_name] => name22 [product_url] => /cms/books/programmer/name22 ) ) ) ) )
PUT: api/checkouts/$id?token=$token (aktualizacja kasy w szczególności pole: is_pay)
Array ( [is_pay] => 1 )
stdClass Object ( [success] => 1 )