#DEFINE ODD          ";"
#DEFINE CRLF         CHR(13)+CHR(10)

DO (LOWER(JUSTPATH(sys(16))) + "\http_ppgm") WITH "https://admin:admin@canteen-backend.alto-testing.mine.nu/"

*HTTP_READ_ONLY_MODE = .T.


*http_request('food/crud/product_ranges', "POST", '{"name":"Jidla"}')  
*http_request('food/crud/product_ranges', "POST", '{"name":"Napoje"}')  


http_request('food/crud/products', "POST", '{"range":1, "name":"KnedloVeproZelo", "description":"Knedle, flaxa, zele", "stock_card_number":654321, "price":"95.00", "price2":"78.00", "tax_rate":"15.00", "tax_rate2":"15.00" }')  
http_request('food/crud/products', "POST", '{"range":2, "name":"Vodka s dzusem", "description":"", "stock_card_number":6521, "price":"145.00", "price2":"80.00", "tax_rate":"21.00", "tax_rate2":"21.00" }')  

http_get    ("food/crud/product_ranges")
http_get    ("food/crud/products")

RETURN 
RETURN 
RETURN 
RETURN 


for  iii = 1 TO 588
    http_request("kredit/crud/client_infos/" + ALLTRIM(STR(m.iii)), "PATCH", '{"pl_c_hlad":1}')
ENDFOR 


DO (LOWER(JUSTPATH(sys(16))) + "\http_ppgm") WITH "https://alto:1991.Altopraha@btr.psp.cz/"


http_request('canteen/crud/orders/74739', "PATCH", '{"ordered":1,"eaten":1}')  
http_request('canteen/crud/orders/74740', "PATCH", '{"ordered":1,"eaten":1}')  







FOR id = 1 TO 566
     ? ALLTRIM(STR(m.id))
     retez = '{ "client":' + ALLTRIM(STR(m.id)) + ', "kind":"POI", "transacted_at":"2019-03-29T00:00:01", "balance":0, "description":"VYUCT", "display_description":"Vyuctovani POI"}'
*     http_request('kredit/crud/historic_transactions', "POST", m.retez)
ENDFOR 





*!*    http://btr.psp.cz/kredit/crud/historic_transactions (0.26sec)
*!*        BODY>>> { "client":2, "kind":"KC", "transacted_at":"2019-03-29T00:00:00", "balance":0, "description":"VYUCT", "display_description":"Vyuctovani"} <<<BODY 
*!*    { "http_status":"201 OK", "historic_transaction":{"id":39761,"client":2,"bill_header":null,"amount":"171.00","balance":"0.00","kind":"KC","transacted_at":"2019-03-29T00:00:00+01:00","description":"VYUCT","display_description":"Vyuctovani"}}




http_request('kredit/crud/historic_transactions/36728', "PATCH", '{"transacted_at":"2019-03-30T11:11:11Z"}')
http_request('kredit/crud/historic_transactions/37608', "PATCH", '{"transacted_at":"2019-03-30T12:12:12Z"}')


USE i:\trans_kc
SCAN
      http_request('kredit/crud/historic_transactions/' + ALLTRIM(STR(id)), "PATCH", '{"kind":"KC"}')
ENDSCAN 

FOR id = 21511 TO -32999
     ? ALLTRIM(STR(m.id))
      http_request('kredit/crud/historic_transactions/' + ALLTRIM(STR(id)), "PATCH", '{"kind":"POI"}')
ENDFOR 

*     http_request('kredit/crud/client_infos/' + ALLTRIM(STR(id)), 'PATCH', '{"limit":0}')

*       http_request('kredit/crud/historic_transactions/' + ALLTRIM(STR(id)), "DELETE", "")




*DO (LOWER(JUSTPATH(sys(16))) + "\ppgm_klienti") &&WITH "loguj"

*http_get    ("kredit/crud/historic_transactions")


FOR iii = 400 to 555
*        http_request('kredit/crud/client_infos/' + ALLTRIM(STR(m.iii)), "PATCH", '{"max_den_odber":1}')
*        http_request('kredit/crud/historic_transactions/' + ALLTRIM(STR(m.iii)), "DELETE", "")

    http_request("kredit/crud/client_infos/" + ALLTRIM(STR(m.iii)), "PATCH", '{"limit":-9992}')


ENDFOR


*http_request('canteen/crud/orders/8901', "PATCH", '{"client":385,"meal":4908,"ordered":1,"eaten":1}')


*{"id":8901,"client":157,"meal":4908,"ordered":1,"eaten":1,"created_at":"2019-01-03T17:45:48.333047Z","updated_at":"2019-01-03T17:45:48.333110Z"}}

RETURN 


*http_request('canteen/crud/orders/7714', "DELETE" )
*http_request('canteen/crud/orders/7715', "DELETE" )



RETURN 

#DEFINE CLIENT_ID_OLD   14
#DEFINE CLIENT_ID_NEW  368

*Sterba    clients/8 --> 368
*Gabrovski clients/14 --> 371


*json = http_request("canteen/crud/orders/6058", "PATCH", '{"client":' + ALLTRIM(STR(CLIENT_ID_NEW)) + '}')
*json = http_request("canteen/crud/orders/6059", "PATCH", '{"client":' + ALLTRIM(STR(CLIENT_ID_NEW)) + '}')
*json = http_request("canteen/crud/orders/6060", "PATCH", '{"client":' + ALLTRIM(STR(CLIENT_ID_NEW)) + '}')


*        http_request('kredit/crud/historic_transactions/1436', "DELETE")



*USE (m.gcdat_path + "transactions")
*INDEX on id TO qwew DESCENDING 
*SCAN FOR displ_desc = "Zavodka                                     "
*        http_request('kredit/crud/historic_transactions/' + ALLTRIM(STR(transactions.id)), "DELETE")
*ENDSCAN 

FOR iii = 1400 to 744 STEP -1
*        http_request('kredit/crud/historic_transactions/' + ALLTRIM(STR(m.iii)), "DELETE")
ENDFOR

*json = http_get("kredit/crud/transactions?page_size=9999")


*http_get(     'canteen/crud/orders?filter{client}=14&page_size=9999' )
*http_request('canteen/crud/orders/5695', "DELETE" )
*http_request('canteen/crud/orders/5696', "DELETE" )
*http_request('canteen/crud/orders/5697', "DELETE" )

*{"id":5695,"client":14,"meal":3916,"ordered":1,"eaten":0,"created_at":"2018-12-12T09:15:17.287276Z","updated_at":"2018-12-12T09:15:17.287321Z"},
*{"id":5696,"client":14,"meal":3957,"ordered":1,"eaten":0,"created_at":"2018-12-12T09:15:17.293434Z","updated_at":"2018-12-12T09:15:17.293471Z"},
*{"id":5697,"client":14,"meal":3963,"ordered":1,"eaten":0,"created_at":"2018-12-12T09:15:17.298325Z","updated_at":"2018-12-12T09:15:17.298362Z"}]}}

*json = http_get    ("auth/crud/users/382")

*rq = '{"password":"sasa"}'
*json = http_request("auth/crud/users/382", "PATCH", m.rq)

*rq = '{"client":371}'
*json = http_request("auth/crud/users/18", "PATCH", m.rq)

RETURN 

FOR iii = 1 to 11
*    http_request("kredit/crud/clients/" + ALLTRIM(STR(m.iii)), "PATCH", '{"company":{"dic":"","ico":"3","name":"HPP"}}')
ENDFOR



*{"id":10,"info":9,"user":13,"status":"A","client_id":"1137","card_id":"1137","chip_id":"047526D25A4E80","email":"formanovan@psp.cz","firstname":"Naďa","surname":"Formanová","comment":"","news":true,"daily_menu":true,"expiration_date":"2000-05-05","personal":{"sex":"M"},"company":{"dic":"","ico":"","name":""}},

*req = '{"expiration_date":"2044-04-04", "company":{"name":"HPP"}}'
*= http_request("kredit/crud/clients/10", "PATCH", m.req)



SET POINT TO (m.o_set_point)
RETURN 


*!*    USE (m.gcpri_path + "orders")
*!*    SCAN FOR client = CLIENT_ID_OLD
*!*        json = http_get    ("canteen/crud/orders/" + ALLTRIM(STR(id)))
*!*        json = http_request("canteen/crud/orders/" + ALLTRIM(STR(id)), "PATCH", '{"client":' + ALLTRIM(STR(CLIENT_ID_NEW)) + '}')
*!*    ENDSCAN 


*!*    USE (m.gcpri_path + "transactions")
*!*    SCAN FOR client = CLIENT_ID_OLD
*!*        json = http_get    ("kredit/crud/transactions/" + ALLTRIM(STR(id)))
*!*        json = http_request("kredit/crud/transactions/" + ALLTRIM(STR(id)), "PATCH", '{"client":' + ALLTRIM(STR(CLIENT_ID_NEW)) + '}')
*!*    ENDSCAN 



*req = '{"id":8,"info":7,"status":"A","user":375,"client_id":"3516","card_id":"3516","chip_id":"043822BA5E3F80","email":"strbar@psp.cz","firstname":"Richard","surname":"Őtrba","comment":"","news":false,"daily_menu":false,"expiration_date":"2055-05-26"}'
*req = '{"surname":"Štrba"}'
*= http_request("kredit/crud/clients/8", "PATCH", m.req)

ACTIVATE SCREEN 


http_get(     'canteen/crud/orders?filter{client}=14&page_size=9999' )
http_get(     'canteen/crud/orders?filter{client}=371&page_size=9999' )

http_get("kredit/crud/transactions?filter{client}=14&page_size=9999")
http_get("kredit/crud/transactions?filter{client}=371&page_size=9999")
