summaryrefslogtreecommitdiff
path: root/anteraja.c
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-28 10:58:50 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-28 10:58:50 +0800
commitc328f6c002446245ae81fc5f6009555ef71d071c (patch)
treedfda50826d8affa1fb3ded1513752a722828406f /anteraja.c
parent52da44669d4ea5f3c00100617644cab8db306273 (diff)
Handle whose status is other than 200
At the same time, refactor the JSON handling.
Diffstat (limited to 'anteraja.c')
-rw-r--r--anteraja.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/anteraja.c b/anteraja.c
index 05fa870..1268820 100644
--- a/anteraja.c
+++ b/anteraja.c
@@ -1,15 +1,16 @@
#include "shipping.h"
#include "handler.h"
-enum {
- BASE_PATH,
- ACCESS_KEY
-};
-
extern CURL *curl;
+static const char *status_trail[] = {
+ "status",
+ NULL
+};
+
void anteraja_init(char *provisions[], struct shipping *shipping)
{
+ enum { BASE_PATH, ACCESS_KEY };
shipping->base = malloc(strlen(provisions[BASE_PATH]) + 1);
strcpy(shipping->base, provisions[BASE_PATH]);
headers(shipping, (const char *[]){ "access-key-id", "secret-access-key", NULL },
@@ -38,13 +39,15 @@ size_t anteraja_services_handle(const char *contents, size_t size, size_t nmemb,
struct pikul_services **services)
{
size_t realsize = size * nmemb;
- handle(contents, realsize, &(struct container){ services, (const char *[]){
+ handle_services(contents, realsize, status_trail, (const char *[]){
+ "content",
+ "services",
+ NULL
+ }, (const char *[]){
"product_code",
"product_name",
"etd",
- "rates",
- "content",
- "services",
- NULL}});
+ "rates"
+ }, services);
return realsize;
}