Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethphough committed Apr 12, 2024
1 parent 180775f commit 6976f33
Show file tree
Hide file tree
Showing 11 changed files with 474 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]"
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
44 changes: 44 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Changes Proposed in This PR
- Clearly outline the changes you have made in this pull request. Provide enough detail for reviewers to understand what has been done and why.
- Include any new features, bug fixes, or enhancements.
- Specify how the changes impact the existing codebase.

### Acceptance Criteria Scenarios
- List the scenarios that need to be tested to ensure the pull request meets the acceptance criteria.
- Describe the expected outcomes for each scenario.

### Linked Issues
- Mention any related issues this pull request addresses or resolves. Include the issue numbers with hyperlinks.

### Implementation Details
- Provide any necessary context or details that could help reviewers understand the implementation approach.
- Discuss any significant choices or trade-offs you made in the development process.

### Dependencies
- List any dependencies that this pull request introduces or changes.
- Ensure all dependencies are documented and justified.

### Testing Strategy
- Describe the testing approach. Mention the types of tests (unit, integration, end-to-end) that have been added or modified.
- Highlight any specific areas of the code that should be focused on during testing.

### Screenshots/Video
- Include screenshots or video captures of new or updated UI/UX elements, if applicable.

### Checklist Before Requesting Review
- [ ] Changes are complete and tested.
- [ ] Pull request targets the correct branch.
- [ ] Code is consistent with the existing codebase.
- [ ] Linter/static analysis passes.
- [ ] Existing tests pass.
- [ ] Documentation and changelog are updated.

### Instructions for Reviewers
- Provide any specific instructions or areas of focus for the reviewers.
- Mention if there are any particular files or modules that require more attention.

### Follow-Up Tasks (If Applicable)
- List any follow-up tasks or next steps that should be taken after the pull request is merged.

### Additional Notes
- Include any other information that would be useful for the reviewers or maintainers.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: C++ Build Workflow

on: [push, pull_request]

jobs:
build:
name: Build Kyte C++ Library
runs-on: ubuntu-latest # You can specify other runners like windows-latest or macos-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libssl-dev -y # Ensure all necessary libraries are installed
- name: Build project
run: |
make -C . # Use make in the root directory where the Makefile is located
- name: Run tests
run: |
./bin/kyte_client # Assuming executable is in the bin directory as per your Makefile setup
53 changes: 53 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"files.associations": {
"string": "cpp",
"bit": "cpp",
"cctype": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"limits": "cpp",
"new": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xutility": "cpp",
"atomic": "cpp",
"bitset": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"ctime": "cpp",
"ios": "cpp",
"istream": "cpp",
"iterator": "cpp",
"memory": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"typeinfo": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocnum": "cpp",
"iomanip": "cpp",
"iostream": "cpp",
"xlocmon": "cpp",
"xloctime": "cpp"
}
}
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Compiler settings - Can be customized.
CXX = g++
CXXFLAGS = -Wall -Iinclude -std=c++11 -O2
LDFLAGS = -lcurl -lssl -lcrypto

# Build directories
SRC_DIR = src
INCLUDE_DIR = include
OBJ_DIR = obj
BIN_DIR = bin

# Find all CPP files in SRC_DIR
SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
# Replace .cpp from SOURCES with .o and prepend OBJ_DIR
OBJECTS = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SOURCES))

# Target executable
TARGET = $(BIN_DIR)/kyte_client

all: build $(TARGET)

build:
@mkdir -p $(BIN_DIR)
@mkdir -p $(OBJ_DIR)

# Link the target with all objects files
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)

# Compile each source file to an object
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@

# Cleanup
clean:
@rm -rf $(OBJ_DIR) $(BIN_DIR)

# Phony targets
.PHONY: all build clean
22 changes: 22 additions & 0 deletions examples/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// main.cpp
#include "../include/kyte/Client.hpp"
#include <iostream>

int main() {
// Initialize the client with sample credentials and endpoint
kyte::Client client("your_public_key", "your_private_key", "your_kyte_account",
"your_kyte_identifier", "https://api.flykyte.io");

// Perform a GET request to a sample model with optional field and value
std::string response = client.get("SampleModel", "SampleField", "SampleValue");

// Print the response to the console
std::cout << "Response from Kyte API: " << response << std::endl;

// Optionally, demonstrate more requests, e.g., POST, PUT, DELETE
std::string postData = "{\"key\":\"value\"}";
std::string postResponse = client.post("SampleModel", postData);
std::cout << "Response from POST to Kyte API: " << postResponse << std::endl;

return 0;
}
41 changes: 41 additions & 0 deletions include/kyte/Client.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Client.hpp
#ifndef KYTE_CLIENT_HPP
#define KYTE_CLIENT_HPP

#include <string>
#include <curl/curl.h>
#include "Util.hpp"

namespace kyte {

class Client {
private:
std::string public_key;
std::string private_key;
std::string kyte_account;
std::string kyte_identifier;
std::string kyte_endpoint;
std::string kyte_app_id;
std::string sessionToken;
std::string transactionToken;

std::string getIdentity(const std::string& timestamp);
std::string getSignature(const std::string& epoch);

public:
Client(const std::string& public_key, const std::string& private_key, const std::string& kyte_account,
const std::string& kyte_identifier, const std::string& kyte_endpoint, const std::string& kyte_app_id = "");

std::string request(const std::string& method, const std::string& model, const std::string& field = "",
const std::string& value = "", const std::string& data = "");

// Methods to expose high-level functionality like post, get, put, delete
std::string post(const std::string& model, const std::string& data);
std::string get(const std::string& model, const std::string& field = "", const std::string& value = "");
std::string put(const std::string& model, const std::string& field, const std::string& value, const std::string& data);
std::string deleteRequest(const std::string& model, const std::string& field, const std::string& value);
};

} // namespace kyte

#endif // KYTE_CLIENT_HPP
17 changes: 17 additions & 0 deletions include/kyte/Util.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Util.hpp
#ifndef KYTE_UTIL_HPP
#define KYTE_UTIL_HPP

#include <string>

namespace kyte {

// Encode data using base64
std::string base64_encode(const std::string& input);

// URL encode a string
std::string url_encode(const std::string& input);

} // namespace kyte

#endif // KYTE_UTIL_HPP
Loading

0 comments on commit 6976f33

Please sign in to comment.