Module: Unifi::Client::Vouchers

Included in:
Unifi::Client
Defined in:
lib/unifi/client/vouchers.rb

Instance Method Summary collapse

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(options = {})
  body = { cmd: 'create-voucher',
           expire: options[:expire] ||= 120,
           n: options[:amount] ||= 1,
           quota: options[:quota] ||= 1 }
  body[:note] = options[:note] if options[:note]
  body[:up] = options[:up] if options[:up]
  body[:down] = options[:down] if options[:down]
  body[:bytes] = options[:bytes] if options[: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