2019-08-01 19:19:02 +00:00
|
|
|
//
|
|
|
|
// Created by lukas on 06.04.19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-05-05 17:25:23 +00:00
|
|
|
#include "Hashmap.h"
|
2019-08-01 19:19:02 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class API {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Simple API get request
|
|
|
|
* @param myurl api url
|
|
|
|
* @return return string of server
|
|
|
|
*/
|
|
|
|
std::string request(std::string myurl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* complex request with post/get and header information support
|
|
|
|
* @param myurl base request url
|
|
|
|
* @param post boolean (false=get)
|
|
|
|
* @param map post/get fields
|
|
|
|
* @param headers header fields
|
|
|
|
* @return return string of server
|
|
|
|
*/
|
2020-05-07 12:54:40 +00:00
|
|
|
std::string request(std::string myurl,
|
|
|
|
bool post,
|
|
|
|
Hashmap<std::string, std::string> &map,
|
|
|
|
std::vector<std::string> &headers);
|
2019-08-01 19:19:02 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static size_t write_data(void *buffer, size_t size, size_t buffersize, FILE *stream);
|
|
|
|
};
|