Crates.io | voucherify_rs |
lib.rs | voucherify_rs |
version | 1.0.0 |
source | src |
created_at | 2017-03-09 11:56:24.88041 |
updated_at | 2019-07-19 09:55:56.594192 |
description | Rust SDK for Voucherify.io |
homepage | https://github.com/voucherifyio/voucherify-rust-sdk |
repository | https://github.com/voucherifyio/voucherify-rust-sdk.git |
max_upload_size | |
id | 8896 |
size | 34,649 |
Add crate to your Cargo.toml
[dependencies]
voucherify_rs = "1.0.0"
Import voucherify-rs crate
extern crate voucherify_rs;
Create voucherify api object
let voucherify = Voucherify::new("<YOUR_APP_ID_GOES_HERE>",
"<YOUR_SECRET_KEY_GOES_HERE>");
Optionally, you can specify API Endpoint if you want to use Voucherify running in a specific region.
let voucherify: &mut Voucherify = &mut Voucherify::new("<YOUR_APP_ID_GOES_HERE>",
"<YOUR_SECRET_KEY_GOES_HERE>");
voucherify.set_endpoint("https://<region>.api.voucherify.io");
Provided methods:
let new_voucher = Voucher::new()
.voucher_type(VoucherType::DISCOUNT_VOUCHER)
.discount(DiscountType::AMOUNT, 20)
.build();
let created_voucher = voucherify.voucher_create(new_voucher).send().unwrap();
let single_voucher: Voucher = voucherify.voucher_get("D1dsWQVE").send().unwrap();
let updated_metadata = Metadata::new()
.number("number", 32)
.string("is", "working")
.boolean("is_amazing", true)
.build();
let updated_voucher = voucherify.voucher_update("D1dsWQVE")
.category("hello_world")
.active(true)
.metadata(updated_metadata)
// .gift_amount(1234)
.send().unwrap();
let was_voucher_deleted: bool = voucherify.voucher_delete(created_voucher_code.as_str()).send().unwrap();
let voucher_list: Vec<Voucher> = voucherify.voucher_list().limit(19).page(1).send().unwrap();
let was_voucher_enabled: bool = voucherify.voucher_enable("D1dsWQVE").send().unwrap();
let was_voucher_disabled: bool = voucherify.voucher_disable("D1dsWQVE").send().unwrap();
Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)
1.0.0
- Added support for custom API endpoint, that allows to connect to projects created in specific Voucherify region.
Additionally, updated the model here and there (more Option-al variables + added simple VouchersList).