Module: Unifi::Client::Vouchers
- Included in:
- Unifi::Client
- Defined in:
- lib/unifi/client/vouchers.rb
Instance Method Summary collapse
- #create_voucher(options = {}) ⇒ Object
- #revoke_voucher(voucher_id = nill) ⇒ Object
- #stat_voucher(create_time = nill) ⇒ Object
Instance Method Details
#create_voucher(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/unifi/client/vouchers.rb', line 7 def create_voucher( = {}) body = { cmd: 'create-voucher', expire: [:expire] ||= 120, n: [:amount] ||= 1, quota: [:quota] ||= 1 } body[:note] = [:note] if [:note] body[:up] = [:up] if [:up] body[:down] = [:down] if [:down] body[:bytes] = [:bytes] if [:bytes] response = self.class.post("/s/#{@site}/cmd/hotspot", { body: body.to_json } ) response.parsed_response end |
#revoke_voucher(voucher_id = nill) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/unifi/client/vouchers.rb', line 28 def revoke_voucher(voucher_id = nill) body = { cmd: 'delete-voucher', _id: voucher_id } response = self.class.post("/s/#{@site}/cmd/hotspot", { body: body.to_json } ) response.parsed_response end |
#stat_voucher(create_time = nill) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/unifi/client/vouchers.rb', line 21 def stat_voucher(create_time = nill) body = { create_time: create_time } response = self.class.get("/s/#{@site}/stat/voucher", { body: body.to_json }) response.parsed_response end |