summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-17 15:29:20 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-17 15:29:20 +0800
commitb999dd2f128bcf209c62d3419a559e70222e7b04 (patch)
tree289e21169fb6ea32c767232be329657bde6168a1
parentdfa57092e26c242c2ab64dc1d029e5dff44eee67 (diff)
Postal codes for both sender & receiver
-rw-r--r--anteraja.c24
-rw-r--r--pikul.c14
-rw-r--r--pikul.h5
-rw-r--r--pikul.i5
4 files changed, 28 insertions, 20 deletions
diff --git a/anteraja.c b/anteraja.c
index b49c07c..89239ab 100644
--- a/anteraja.c
+++ b/anteraja.c
@@ -20,13 +20,15 @@
\"name\":\"%s\",\
\"phone\":\"%s\",\
\"district\":\"%s\",\
-\"address\":\"%s\"\
+\"address\":\"%s\",\
+\"postcode\":\"%s\"\
},\
\"receiver\":{\
\"name\":\"%s\",\
\"phone\":\"%s\",\
\"district\":\"%s\",\
-\"address\":\"%s\"\
+\"address\":\"%s\",\
+\"postcode\":\"%s\"\
},\
\"items\":[\
%s\
@@ -96,9 +98,9 @@ size_t anteraja_services_handle(const char *contents, size_t size, size_t nmemb,
void anteraja_order(const char *order_number, const char *service, const char *sender_name,
const char *sender_phone, const char *origin, const char *sender_address,
- const char *receiver_name, const char *receiver_phone, const char *destination,
- const char *receiver_address, int nitems, char **items[], _Bool insurance, double subtotal,
- char **url, char **post)
+ const char *sender_postal, const char *receiver_name, const char *receiver_phone,
+ const char *destination, const char *receiver_address, const char *receiver_postal,
+ int nitems, char **items[], _Bool insurance, double subtotal, char **url, char **post)
{
*url = malloc(strlen(shipping.base) + strlen(ORDER_PATH) + 1);
sprintf(*url, "%s%s", shipping.base, ORDER_PATH);
@@ -130,12 +132,14 @@ void anteraja_order(const char *order_number, const char *service, const char *s
}
*post = malloc(strlen(ORDER_POST) + strlen(prefix) + strlen(order_number) + strlen(service)
+ ORDER_WEIGHT + strlen(sender_name) + strlen(sender_phone) + strlen(origin)
- + strlen(sender_address) + strlen(receiver_name) + strlen(receiver_phone)
- + strlen(destination) + strlen(receiver_address) + strlen(json) + ORDER_INSURANCE
- + ORDER_SUBTOTAL - 13 * strlen("%s") - 2 * strlen("%d") + 1);
+ + strlen(sender_address) + strlen(sender_postal) + strlen(receiver_name)
+ + strlen(receiver_phone) + strlen(destination) + strlen(receiver_address)
+ + strlen(receiver_postal) + strlen(json) + ORDER_INSURANCE + ORDER_SUBTOTAL
+ - 15 * strlen("%s") - 2 * strlen("%d") + 1);
sprintf(*post, ORDER_POST, prefix, order_number, service, (int)total_weight, sender_name,
- sender_phone, origin, sender_address, receiver_name, receiver_phone, destination,
- receiver_address, json, insurance ? "true" : "false", (int)subtotal);
+ sender_phone, origin, sender_address, sender_postal, receiver_name, receiver_phone,
+ destination, receiver_address, receiver_postal, json, insurance ? "true" : "false",
+ (int)subtotal);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, *post);
}
diff --git a/pikul.c b/pikul.c
index 5f04136..cb74feb 100644
--- a/pikul.c
+++ b/pikul.c
@@ -14,8 +14,8 @@ extern void anteraja_init(char *[]);
extern void anteraja_services(const char *, const char *, double, char **, char **);
extern size_t anteraja_services_handle(const char *, size_t, size_t, struct pikul_services **);
extern void anteraja_order(const char *, const char *, const char *, const char *, const char *,
- const char *, const char *, const char *, const char *, const char *, int,
- char **[], _Bool, double, char **, char **);
+ const char *, const char *, const char *, const char *, const char *, const char *,
+ const char *, int, char **[], _Bool, double, char **, char **);
extern size_t anteraja_order_handle(const char *, size_t size, size_t nmemb, char **);
extern void anteraja_cleanup();
@@ -114,8 +114,9 @@ double pikul_cost(const char *origin, const char *destination, double weight, co
char *pikul_order(const char *order_number, const char *service, const char *sender_name,
const char *sender_phone, const char *origin, const char *sender_address,
- const char *receiver_name, const char *receiver_phone, const char *destination,
- const char *receiver_address, int nitems, char **items[], _Bool insurance, double subtotal)
+ const char *sender_postal, const char *receiver_name, const char *receiver_phone,
+ const char *destination, const char *receiver_address, const char *receiver_postal,
+ int nitems, char **items[], _Bool insurance, double subtotal)
{
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &waybill);
char *url;
@@ -124,8 +125,9 @@ char *pikul_order(const char *order_number, const char *service, const char *sen
switch (shipping.company) {
case PIKUL_ANTERAJA:
anteraja_order(order_number, service, sender_name, sender_phone, origin,
- sender_address, receiver_name, receiver_phone, destination,
- receiver_address, nitems, items, insurance, subtotal, &url, &post);
+ sender_address, sender_postal, receiver_name, receiver_phone,
+ destination, receiver_address, receiver_postal, nitems, items,
+ insurance, subtotal, &url, &post);
handler = anteraja_order_handle;
break;
default:
diff --git a/pikul.h b/pikul.h
index 623c87a..07db738 100644
--- a/pikul.h
+++ b/pikul.h
@@ -27,8 +27,9 @@ void pikul_free_services(struct pikul_services *services);
double pikul_cost(const char *origin, const char *destination, double weight, const char *service);
char *pikul_order(const char *order_number, const char *service, const char *sender_name,
const char *sender_phone, const char *origin, const char *sender_address,
- const char *receiver_name, const char *receiver_phone, const char *destination,
- const char *receiver_address, int nitems, char **items[], _Bool insurance, double subtotal);
+ const char *sender_postal, const char *receiver_name, const char *receiver_phone,
+ const char *destination, const char *receiver_address, const char *receiver_postal,
+ int nitems, char **items[], _Bool insurance, double subtotal);
void pikul_cleanup();
#ifdef __cplusplus
diff --git a/pikul.i b/pikul.i
index 9defe86..aa4c707 100644
--- a/pikul.i
+++ b/pikul.i
@@ -50,6 +50,7 @@ void pikul_init(enum pikul_company company, char *provisions[]);
double pikul_cost(const char *origin, const char *destination, double weight, const char *service);
char *pikul_order(const char *order_number, const char *service, const char *sender_name,
const char *sender_phone, const char *origin, const char *sender_address,
- const char *receiver_name, const char *receiver_phone, const char *destination,
- const char *receiver_address, int nitems, char **items[], _Bool insurance, double subtotal);
+ const char *sender_postal, const char *receiver_name, const char *receiver_phone,
+ const char *destination, const char *receiver_address, const char *receiver_postal,
+ int nitems, char **items[], _Bool insurance, double subtotal);
void pikul_cleanup();