summaryrefslogtreecommitdiff
path: root/interchange
diff options
context:
space:
mode:
Diffstat (limited to 'interchange')
-rw-r--r--interchange/admin.h39
-rw-r--r--interchange/member.h79
-rw-r--r--interchange/ord.h37
-rw-r--r--interchange/typedefs.h18
4 files changed, 173 insertions, 0 deletions
diff --git a/interchange/admin.h b/interchange/admin.h
new file mode 100644
index 0000000..d0e47d7
--- /dev/null
+++ b/interchange/admin.h
@@ -0,0 +1,39 @@
+#ifndef INTERCHANGE_ADMIN_H
+#define INTERCHANGE_ADMIN_H
+
+#include "typedefs.h"
+
+enum interchange_admin_group {
+ INTERCHANGE_ADMIN_GROUP_CONTENT,
+ INTERCHANGE_ADMIN_GROUP_MERCH,
+ INTERCHANGE_ADMIN_GROUP_ORDERS
+};
+
+struct interchange_admin {
+ char *username;
+ char *password;
+ char *name;
+ bool super;
+ enum interchange_admin_group group;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void interchange_admin_login(const char *username, const char *password, void (*handler)(interchange_response *),
+ void (*callback)(struct interchange_admin *));
+void interchange_admin_new_admin(const char *username, const char *password, const char *name, bool super,
+ enum interchange_admin_group group, void (*handler)(interchange_response *));
+void interchange_admin_new_item(const char *description, const char *comment, const char *price,
+ const char *image_path, void (*handler)(interchange_response *));
+void interchange_admin_new_transaction(const struct interchange_ord_order *order,
+ const struct interchange_member *member, bool new_customer_id,
+ void (*handler)(interchange_response *));
+void interchange_admin_logout(struct interchange_admin *admin, void (*handler)(interchange_response *));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/interchange/member.h b/interchange/member.h
new file mode 100644
index 0000000..0e9ca91
--- /dev/null
+++ b/interchange/member.h
@@ -0,0 +1,79 @@
+#ifndef INTERCHANGE_MEMBER_H
+#define INTERCHANGE_MEMBER_H
+
+#include <stdbool.h>
+#include "typedefs.h"
+
+struct interchange_member_preferences {
+ bool mv_same_billing;
+ bool email_copy;
+};
+
+struct interchange_member {
+ char *username;
+ char *usernick;
+ char *password;
+ char *expiration;
+ char *acl;
+ char *mod_time;
+ char *s_nickname;
+ char *company;
+ char *fname; /*!< Shipping first name */
+ char *lname; /*!< Shipping last name */
+ char *address1;
+ char *address2;
+ char *address3;
+ char *city;
+ char *state;
+ char *zip;
+ char *country;
+ char *phone_day;
+ char *mv_shipmode;
+ char *b_nickname;
+ char *b_fname; /*!< Billing first name */
+ char *b_lname; /*!< Billing last name */
+ char *b_company;
+ char *b_address1;
+ char *b_address2;
+ char *b_address3;
+ char *b_city;
+ char *b_state;
+ char *b_zip;
+ char *b_country;
+ char *b_phone;
+ char *p_nickname;
+ char *email;
+ char *fax;
+ char *phone_night;
+ char *address_book;
+ char *accounts;
+ struct interchange_member_preferences *preferences;
+ char *carts;
+ char *owner;
+ char *file_acl;
+ char *db_acl;
+ char *mail_list;
+ char *credit_limit;
+ bool inactive;
+ bool dealer;
+ char *price_level;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void interchange_member_newaccount(const char *username, const char *password, const char *verify,
+ void (*handler)(interchange_response *), void (*callback)(struct interchange_member *));
+ void interchange_member_login(const char *username, const char *password, void (*handler)(interchange_response *),
+ void (*callback)(struct interchange_member *));
+ void interchange_member_account(const char *fname, const char *lname, const char *address1, const char *address2,
+ const char *city, const char *state, const char *zip, const char *email, const char *phone_day);
+ void interchange_member_changepassword(const char *password_old, const char *password, const char *verify);
+ void interchange_member_logout(struct interchange_member *member);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/interchange/ord.h b/interchange/ord.h
new file mode 100644
index 0000000..c62bcf0
--- /dev/null
+++ b/interchange/ord.h
@@ -0,0 +1,37 @@
+#ifndef INTERCHANGE_ORD_H
+#define INTERCHANGE_ORD_H
+
+struct interchange_ord_item {
+ struct interchange_product *product;
+ unsigned int quantity;
+};
+
+struct interchange_ord_order {
+ double subtotal;
+ double shipping;
+ double total_cost;
+ char *profile;
+ size_t nitems;
+ struct interchange_ord_item *items[];
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ * \brief For putting an item to a cart.
+ * \param sku The SKU of the item to order.
+ * \param catalog The catalog from which the item is.
+ * \param order The address of an order instance.
+ */
+void interchange_ord_order(const char *sku, const struct interchange_catalog *catalog,
+ struct interchange_ord_order **order);
+void interchange_ord_checkout(const struct interchange_ord_order *order, const struct interchange_member *member);
+void interchange_ord_free(struct interchange_ord_order *order);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/interchange/typedefs.h b/interchange/typedefs.h
new file mode 100644
index 0000000..02a412f
--- /dev/null
+++ b/interchange/typedefs.h
@@ -0,0 +1,18 @@
+#ifndef INTERCHANGE_TYPEDEFS_H
+#define INTERCHANGE_TYPEDEFS_H
+
+#include <stddef.h>
+#ifdef __EMSCRIPTEN__
+#include <emscripten/fetch.h>
+typedef emscripten_fetch_t interchange_response;
+#else
+#include <curl/curl.h>
+typedef struct {
+ void *userData;
+ char *data;
+ size_t numBytes;
+ CURL *curl;
+} interchange_response;
+#endif
+
+#endif