diff options
Diffstat (limited to 'sicepat.c')
-rw-r--r-- | sicepat.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sicepat.c b/sicepat.c new file mode 100644 index 0000000..9ea4af5 --- /dev/null +++ b/sicepat.c @@ -0,0 +1,41 @@ +#include <stdlib.h> +#include <string.h> +#include "private.h" + +#define BASE "http://api.sicepat.com/customer/" + +const char **sicepat_init(char *provisions[]) +{ + shipping.base = malloc(strlen(BASE) + 1); + strcpy(shipping.base, BASE); + static const char *status_trail[] = { + "sicepat", + "status", + "code", + NULL + }; + shipping.status_trail = status_trail; + static const char *fields[] = { "api-key", NULL }; + return fields; +} + +const char **sicepat_services(const char *origin, const char *destination, double weight) +{ + shipping.url = malloc(strlen(shipping.base) + strlen("tariff?origin=") + strlen(origin) + + strlen("&destination=") + strlen(destination) + strlen("&weight=") + 9); + 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; +} |