Authorization
Der Benutzer ruft auf unserem Shop den Link
/shop/module/kamBox/Shop/authorize
auf.
Er wird zum SmartSso weitergeleitet
--> https://id.smart.telekom-dienste.de/oauth/authorize
und loggt sich dort ein und wird zu uns weitergeleitet.
OAuth Authentifizierung
Wir fragen ein AccessToken an.
https://id.smart.telekom-dienste.de/oauth/token
und senden die Parameter:
{ "oAuthCurlParameters": { "client_id": "JuURftM2z0ACCWDlhREfgrdsfsdf6xJ4XOQqzXrpfmRs9dgD8", "client_secret": "6PD9iE4c_tjpdfdfhMe7YAYAYC8foYQff-vLfWFpAaLAFjnZg", "code": "A9i9T8wMcVorDGKKjLTSwdsfsdfqaj72rLdtZ1Rz97dvESsU0", "redirect_uri": "https://telekom-onlinedruckerei-kambox.johnen-portal.de/shop/module/kamBox/Shop/token", "grant_type": "authorization_code" } }
Als Antwort bekommen wir:
{ "access_token": "eyJraWQiOiJKdVVSZnRNMnowQUNDV0RsaFJFZmdyNnhKNFhPUXF6WHJwZm1SczlkZ0Q4IiwiYWxnIjoiSFM1MTIifQ.eyJpc3MiOiJTbWFydCBTU08iLCJpYXQiOjE3MjQ5MjkxODQsImp0aSI6ImY1N2Y3ZmNlLTZkZWMtNDQxNC05MWYyLWM2ODk3NmY4NjlhYyIsImV4cCI6MTcyNDkzMDk4NCwidXNlciI6eyJpZCI6IjUxMTc1ZTY5LTdmZTktNDA2Mi1hYmI1LTJiODAwMDkyNDExOSIsImVtYWlsIjoiZmlnZW4uYmVzZW5za2lAdGVsZWtvbS5kZSIsImZpcnN0X25hbWUiOiJGaWdlbiIsImxhc3RfbmFtZSI6IkJlc2Vuc2tpIiwicm9sZSI6MCwibWVtYmVyc2hpcF9pZCI6IjM0YmI3OTdlLTcyYzktNDAwYi04ZDE3LTlhMmQ3NzIwZTZiYyIsInRva2VuX2ZpbmdlcnByaW50IjoiZjZlNjE4NzUwYmM0OWFlYTczYWQzMmI5NzQ4NzMxNjAifX0.5LaziG6DSjr-pxxLS2sN51fvUTvQxx_0tEFxaEQIQwldA6I1Wvf29x2SPhAJM-grP2pG3-KTEuSmo7Az2BRlxw", "token_type": "Bearer", "expires_in": 1800, "refresh_token": "OXJ40Xl5fqqDkEprELOWv6d4RyezdZHbkYMm04wyGwyJGslSA64lS9-OXc0R3KYM5rhEcKBkdh0tbWK1rVzJw", "scope": "read write", "created_at": 1724929184, "id": "51175e69-7fe9-4062-abb5-2b8000924119", "email": "someone@telekom.de", "first_name": "Someone", "last_name": "Someone", "role": "user", "group_ids": [ { "group_id": "7cac39cc-2154-4bd9-98db-08afe5525d57", "parent_id": "b2033f86-c36e-4453-86da-d43c36d0b3a9" }, { "group_id": "95474434-e24f-49b4-af37-62aabd072386", "parent_id": null }, { "group_id": "294e4e83-69e4-4c41-8e7a-d0cd28508e62", "parent_id": "7cacf9cc-2154-4bd9-98db-08afe5525d57" }, { "group_id": "b0617e73-71ba-4304-8fed-0ee1c4f00268", "parent_id": null }, { "group_id": "027cc83f-fda7-442e-bf6b-6248e39a7fe9", "parent_id": "b595fae1-2a5c-49d0-8764-ed9e01c44ab6" }, { "group_id": "97383e1f-0be1-48aa-beab-66e76e80ac07", "parent_id": "7cacf9cc-2154-4bd9-98db-08afe5525d57" } ], "vo_number": "00000", "vp_number": "" }
Benutzer abfragen
Wir rufen mit dem AccessToken
https://regioshop-api.smarttest.8s.de/api/users/me
auf (ohne Parameter).
Als Antwort bekommen wir:
{ "id": 52, "email": "someone@telekom.de", "first_name": "Someone", "last_name": "Someone", "role": "user", "created_at": "2024-08-02T08:59:13.769+02:00", "updated_at": "2024-08-29T11:57:57.981+02:00", "user_regions": [ { "id": 97, "region_id": 34 }, { "id": 98, "region_id": 36 }, { "id": 99, "region_id": 40 } ], "region_ids": [ 34, 36, 40 ], "full_name": "Someone", "extern_region_id": 36, "extern_wallet": { "id": 26, "budget_id": 91, "year": 2024, "quarter": 3, "amount": "358.0", "spending_amount": "0.0", "created_at": "2024-08-20T16:42:02.226+02:00", "updated_at": "2024-08-20T16:42:02.236+02:00", "parent_budget_id": 36, "currency": { "id": 5, "name": "EUR", "symbol": "€", "code": "EUR" } } }
Wir prüfen ob der Benutzer mit der id als customer_user_name vorhanden ist.
Wenn ja aktualisieren wir die Daten für die Felder (falls vorhanden in der Antwort):
'customer_longname'
'customer_firstname'
'customer_lastname'
'customer_user_company1'
'customer_user_street'
'customfield1'
'customer_user_zip'
'customer_user_town'
'customer_user_email'
'customer_user_budgetgruppe__id'
Wenn der Benutzer nicht vorhanden ist legen wir ihn mit der id als customer_user_name und den o.g. Feldern an.
Bestellung senden
Wir rufen den Endpunkt
https://regioshop-api.smarttest.8s.de/api/extern_orders
auf und übergeben als Daten:
{ "address_attributes": { "first_name": "Someone", "last_name": "Someone", "company": "SomeCorp", "street": "Testweg", "zipcode": "30419", "city": "Willich", "number": "15" }, "order_items_attributes": [ { "price": 26.1, "quantity": 500, "product_attributes": { "name": "Visitenkarte f\\u00fcr die Glasfaser Vorregistrierung" } } ] }
Als Antwort erhalten wir.
{ "stdClass": { "id": 38, "created_at": "2024-08-29T13:05:51.145+02:00", "updated_at": "2024-08-29T13:05:51.241+02:00", "status": "completed", "progress": 100, "location": "extern", "created_by": { "id": 52, "name": "Someone" }, "address_recipient": "Someone", "managers": [ { "id": 52, "name": "Someone", "email": "someone@telekom.de" } ], "region": { "id": 36, "name": "Local Team" }, "order_items": { "id": 54, "price": "0.0522", "quantity": 500, "status": "completed", "delivery_status": "pending", "product": { "id": 122, "name": "Visitenkarte für die Glasfaser Vorregistrierung", "packaging_unit": 1, "stockable": false, "payment_type": "direct", "original_product_id": 121 }, "category": { "id": 7, "name": "Extern" }, "currency": { "id": 5, "name": "EUR", "symbol": "€" }, "order": { "id": 38, "manager_ids": [ 52 ], "created_at": "2024-08-29T13:05:51.145+02:00", "address": { "id": 81, "first_name": "Someone", "last_name": "Someone", "company": "SomeCorp", "street": "Testweg", "number": 15, "city": "Willich", "zipcode": "30419" } }, "images_thumbnail_urls": [] }, "address": { "id": 81, "first_name": "Someone", "last_name": "Someone", "company": "SomeCorp", "street": "Testweg", "number": 15, "city": "Willich", "zipcode": "30419" }, } }