1+ <?php
2+
3+ /**
4+ * Summary of Order
5+ */
6+ Class Order
7+ {
8+ private $ name ;
9+ private $ house_number ;
10+ private $ address ;
11+ private $ city ;
12+ private $ postal_code ;
13+ var $ telephone ;
14+ var $ country ;
15+ static $ request_label = false ;
16+ static $ is_return = false ;
17+ var $ parcel_handover_date ;
18+ static $ quantity = 1 ;
19+ var $ shipment_id ;
20+ var $ weight ;
21+ static $ order_number = random_bytes (32 );
22+ static $ url = "https://panel.sendcloud.sc/api/v2/parcel " ;
23+
24+ /**
25+ * Summary of __construct
26+ * @param mixed $name
27+ * @param mixed $house_number
28+ * @param mixed $address
29+ * @param mixed $city
30+ * @param mixed $postal_code
31+ * @param mixed $telephone
32+ * @param mixed $country
33+ * @param mixed $parcel_handover_date
34+ * @param mixed $weight
35+ */
36+ function __construct ($ name , $ house_number , $ address , $ city , $ postal_code , $ telephone , $ country , $ parcel_handover_date , $ weight ){
37+ $ this ->name = $ name ;
38+ $ this ->house_number = $ house_number ;
39+ $ this ->address = $ address ;
40+ $ this ->city = $ city ;
41+ $ this ->postal_code = $ postal_code ;
42+ $ this ->telephone = $ telephone ;
43+ $ this ->country = $ country ;
44+ $ this ->parcel_handover_date = $ parcel_handover_date ;
45+ $ this ->weight = $ weight ;
46+ }
47+
48+ function Create (): string
49+ {
50+ $ ch = curl_init ();
51+ curl_setopt ($ ch , CURLOPT_URL , $ this ->url );
52+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ this ->ParamsToHTTP ());
53+ $ result = curl_exec ($ ch );
54+ return $ result ;
55+
56+ }
57+
58+ function ParamsToHTTP (): string
59+ {
60+ $ body = ["parcel " =>["name " =>$ this ->name ,"house_number " =>$ this ->house_number ,"address " =>$ this ->address ,"city " =>$ this ->city ,"postal_code " =>$ this ->postal_code ,"telephone " =>$ this ->telephone ,"country " =>$ this ->country ,"request_label " =>$ this ->request_label ,"is_return " =>$ this ->is_return ,"parcel_handover_date " =>$ this ->parcel_handover_date ,"quantity " =>$ this ->quantity ,"shipment_id " =>$ this ->shipment_id ,"weight " =>$ this ->weight ,"order_number " =>$ this ->order_number ]];
61+ return http_build_query ($ body );
62+ }
63+ }
0 commit comments