Add crate to your Cargo.toml
toml
[dependencies]
voucherify_rs = "1.0.0"
Import voucherify-rs crate
rust
extern crate voucherify_rs;
Create voucherify api object
rust
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.
``` rust
let voucherify: &mut Voucherify = &mut Voucherify::new("
voucherify.set_endpoint("https://
Provided methods: - Create Voucher - Get Voucher - Update Voucher - Delete Voucher - List Vouchers - Enable Voucher - Disable Voucher
``` rust let newvoucher = Voucher::new() .vouchertype(VoucherType::DISCOUNT_VOUCHER) .discount(DiscountType::AMOUNT, 20) .build();
let createdvoucher = voucherify.vouchercreate(new_voucher).send().unwrap(); ```
rust
let single_voucher: Voucher = voucherify.voucher_get("D1dsWQVE").send().unwrap();
``` rust let updatedmetadata = Metadata::new() .number("number", 32) .string("is", "working") .boolean("isamazing", true) .build();
let updatedvoucher = voucherify.voucherupdate("D1dsWQVE") .category("helloworld") .active(true) .metadata(updatedmetadata) // .gift_amount(1234) .send().unwrap(); ```
rust
let was_voucher_deleted: bool = voucherify.voucher_delete(created_voucher_code.as_str()).send().unwrap();
rust
let voucher_list: Vec<Voucher> = voucherify.voucher_list().limit(19).page(1).send().unwrap();
rust
let was_voucher_enabled: bool = voucherify.voucher_enable("D1dsWQVE").send().unwrap();
rust
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).