Objectively
Object oriented framework for 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 *userData);
51
62struct RESTClient {
63
68
73 RESTClientInterface *interface[0];
74
79};
80
84struct RESTClientInterface {
85
89 ObjectInterface objectInterface;
90
102 int (*del)(RESTClient *self, const char *url, const char **headers, Data **data);
103
115 void (*delAsync)(RESTClient *self, const char *url, const char **headers,
116 RESTClientCompletion completion, void *userData);
117
129 int (*get)(RESTClient *self, const char *url, const char **headers, Data **data);
130
142 void (*getAsync)(RESTClient *self, const char *url, const char **headers,
143 RESTClientCompletion completion, void *userData);
144
155 int (*head)(RESTClient *self, const char *url, const char **headers);
156
168 void (*headAsync)(RESTClient *self, const char *url, const char **headers,
169 RESTClientCompletion completion, void *userData);
170
178 RESTClient *(*init)(RESTClient *self);
179
188 RESTClient *(*initWithSession)(RESTClient *self, URLSession *session);
189
201 int (*options)(RESTClient *self, const char *url, const char **headers, Data **data);
202
214 void (*optionsAsync)(RESTClient *self, const char *url, const char **headers,
215 RESTClientCompletion completion, void *userData);
216
229 int (*patch)(RESTClient *self, const char *url, const Data *body, const char **headers, Data **data);
230
243 void (*patchAsync)(RESTClient *self, const char *url, const Data *body, const char **headers,
244 RESTClientCompletion completion, void *userData);
245
258 int (*post)(RESTClient *self, const char *url, const Data *body, const char **headers, Data **data);
259
272 void (*postAsync)(RESTClient *self, const char *url, const Data *body, const char **headers,
273 RESTClientCompletion completion, void *userData);
274
287 int (*put)(RESTClient *self, const char *url, const Data *body, const char **headers, Data **data);
288
301 void (*putAsync)(RESTClient *self, const char *url, const Data *body, const char **headers,
302 RESTClientCompletion completion, void *userData);
303
310 RESTClient *(*sharedInstance)(void);
311
312};
313
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:342
#define OBJECTIVELY_EXPORT
Definition Types.h:36
A management context for loading resources via URLs.
void(* RESTClientCompletion)(int status, Data *data, void *userData)
A completion handler for asynchronous RESTClient requests.
Definition RESTClient.h:50
The runtime representation of a Class.
Definition Class.h:90
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:62
RESTClientInterface * interface[0]
The interface type.
Definition RESTClient.h:73
URLSession * session
The URLSession backing this client.
Definition RESTClient.h:78
Object object
The superclass.
Definition RESTClient.h:67
A management context for loading resources via URLs.
Definition URLSession.h:57