Objectively
Ultra-lightweight object oriented framework for GNU C.
Loading...
Searching...
No Matches
RESTClient.h
Go to the documentation of this file.
1/*
2 * Objectively: Ultra-lightweight object oriented framework for GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
36typedef struct RESTClient RESTClient;
37typedef struct RESTClientInterface RESTClientInterface;
38
39#include <Objectively/Data.h>
40#include <Objectively/Object.h>
42
50typedef void (*RESTClientCompletion)(int status, Data *data, void *user_data);
51
61struct RESTClient {
62
67
72 RESTClientInterface *interface;
73
78};
79
83struct RESTClientInterface {
84
88 ObjectInterface objectInterface;
89
99 int (*get)(RESTClient *self, const char *url, Data **data);
100
110 void (*getAsync)(RESTClient *self, const char *url,
111 RESTClientCompletion completion, void *user_data);
112
121 int (*head)(RESTClient *self, const char *url);
122
132 void (*headAsync)(RESTClient *self, const char *url,
133 RESTClientCompletion completion, void *user_data);
134
144 int (*httpDelete)(RESTClient *self, const char *url, Data **data);
145
155 void (*httpDeleteAsync)(RESTClient *self, const char *url,
156 RESTClientCompletion completion, void *user_data);
157
165 RESTClient *(*init)(RESTClient *self);
166
175 RESTClient *(*initWithSession)(RESTClient *self, URLSession *session);
176
186 int (*options)(RESTClient *self, const char *url, Data **data);
187
197 void (*optionsAsync)(RESTClient *self, const char *url,
198 RESTClientCompletion completion, void *user_data);
199
210 int (*patch)(RESTClient *self, const char *url, const Data *body, Data **data);
211
222 void (*patchAsync)(RESTClient *self, const char *url, const Data *body,
223 RESTClientCompletion completion, void *user_data);
224
235 int (*post)(RESTClient *self, const char *url, const Data *body, Data **data);
236
247 void (*postAsync)(RESTClient *self, const char *url, const Data *body,
248 RESTClientCompletion completion, void *user_data);
249
260 int (*put)(RESTClient *self, const char *url, const Data *body, Data **data);
261
272 void (*putAsync)(RESTClient *self, const char *url, const Data *body,
273 RESTClientCompletion completion, void *user_data);
274
281 RESTClient *(*sharedInstance)(void);
282
283};
284
static Data * data(void)
Definition Data.c:286
Data buffers.
Object is the root Class of The Objectively Class hierarchy.
OBJECTIVELY_EXPORT Class * _RESTClient(void)
Definition RESTClient.c:332
#define OBJECTIVELY_EXPORT
Definition Types.h:36
A management context for loading resources via URLs.
void(* RESTClientCompletion)(int status, Data *data, void *user_data)
A completion handler for asynchronous RESTClient requests.
Definition RESTClient.h:50
The runtime representation of a Class.
Definition Class.h:95
Data buffers.
Definition Data.h:50
Object is the root Class of The Objectively Class hierarchy.
Definition Object.h:46
An HTTP REST client backed by URLSession.
Definition RESTClient.h:61
URLSession * session
The URLSession backing this client.
Definition RESTClient.h:77
Object object
The superclass.
Definition RESTClient.h:66
RESTClientInterface * interface
The interface.
Definition RESTClient.h:72
A management context for loading resources via URLs.
Definition URLSession.h:57