From 017f4c4312444c1ba386d6e0f6192fdc40f03c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sun, 25 Jul 2021 11:48:32 +0800 Subject: Origin & destination info retrieval implementations --- sicepat.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'sicepat.c') diff --git a/sicepat.c b/sicepat.c index 9dd3d19..549bdfc 100644 --- a/sicepat.c +++ b/sicepat.c @@ -3,6 +3,8 @@ #include "private.h" #define BASE "http://api.sicepat.com/customer/" +#define ORIGINS "origin" +#define DESTINATIONS "destination" const char **sicepat_init(char *provisions[]) { @@ -20,6 +22,46 @@ const char **sicepat_init(char *provisions[]) return fields; } +const char **sicepat_origins() +{ + struct shipping *shipping = shipping_list[PIKUL_SICEPAT]; + shipping->url = malloc(strlen(BASE) + strlen(ORIGINS) + 1); + sprintf(shipping->url, "%s%s", BASE, ORIGINS); + static const char *trail[] = { + "sicepat", + "results", + NULL + }; + shipping->trail = trail; + static const char *attributes[] = { + "origin_code", + NULL, + "origin_name", + NULL + }; + return attributes; +} + +const char **sicepat_destinations() +{ + struct shipping *shipping = shipping_list[PIKUL_SICEPAT]; + shipping->url = malloc(strlen(BASE) + strlen(DESTINATIONS) + 1); + sprintf(shipping->url, "%s%s", BASE, DESTINATIONS); + static const char *trail[] = { + "sicepat", + "results", + NULL + }; + shipping->trail = trail; + static const char *attributes[] = { + "destination_code", + "subdistrict", + "city", + "province" + }; + return attributes; +} + const char **sicepat_services(const char *origin, const char *destination, double weight) { struct shipping *shipping = shipping_list[PIKUL_SICEPAT]; -- cgit v1.2.3