diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-19 17:38:51 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-19 17:38:51 +0800 |
commit | 3533297ec2cf539672a362ff931d0b15c9cb38ff (patch) | |
tree | 15d2ab09c8c4b2a6863ec05f29146875ed0b39e7 /sicepat.c | |
parent | 531aaf6e9d01a4ae3257579996681bbe8246630f (diff) | |
parent | 74028cd953f94cfd2d0a1f635ed07e25d94c6802 (diff) |
Merge branch 'master' into sicepat
Diffstat (limited to 'sicepat.c')
-rw-r--r-- | sicepat.c | 61 |
1 files changed, 30 insertions, 31 deletions
@@ -1,42 +1,41 @@ -#include "common.h" +#include <stdlib.h> +#include <string.h> +#include "private.h" #define BASE "http://api.sicepat.com/customer/" -static const char *status_trail[] = { - "sicepat", - "status", - "code", - NULL -}; - -void sicepat_init(char *provisions[]) +const char **sicepat_init(char *provisions[]) { shipping.base = malloc(strlen(BASE) + 1); strcpy(shipping.base, BASE); - headers((const char *[]){ "api-key", NULL }, provisions); + static const char *status_trail[] = { + "sicepat", + "status", + "code", + NULL + }; + shipping.status_trail = status_trail; + static const char *fields[] = { "api-key", NULL }; + return fields; } -void sicepat_services(const char *origin, const char *destination, double weight, char **url) +const char **sicepat_services(const char *origin, const char *destination, double weight) { - *url = malloc(strlen(shipping.base) + strlen("tariff?origin=") + strlen(origin) + shipping.url = malloc(strlen(shipping.base) + strlen("tariff?origin=") + strlen(origin) + strlen("&destination=") + strlen(destination) + strlen("&weight=") + 9); - sprintf(*url, "%stariff?origin=%s&destination=%s&weight=%f", shipping.base, origin, destination, - weight); -} - -size_t sicepat_services_handle(const char *contents, size_t size, size_t nmemb, - struct pikul_services **services) -{ - size_t realsize = size * nmemb; - handle(SERVICES, contents, realsize, status_trail, (const char *[]){ - "sicepat", - "results", - NULL - }, (const char *[]){ - "service", - "description", - "etd", - "tariff" - }, services); - return realsize; + sprintf(shipping.url, "%stariff?origin=%s&destination=%s&weight=%f", shipping.base, origin, + destination, weight); + static const char *trail[] = { + "sicepat", + "results", + NULL + }; + shipping.trail = trail; + static const char *attributes[] = { + "service", + "description", + "etd", + "tariff" + }; + return attributes; } |