Class: Pushover::Licenses
- Inherits:
-
Object
- Object
- Pushover::Licenses
- Defined in:
- lib/pushover/licenses.rb
Overview
Licenses provides operations for the Licensing API.
Constant Summary collapse
- OPERATING_SYSTEMS =
['Android', 'iOS', 'Desktop'].freeze
Instance Method Summary collapse
-
#assign(user: nil, email: nil, os: nil) ⇒ Response
Permanently assign one prepaid license credit to a user or e-mail address.
-
#get ⇒ Response
Retrieve the application's available prepaid license credits.
-
#initialize(client) ⇒ Licenses
constructor
A new instance of Licenses.
Constructor Details
#initialize(client) ⇒ Licenses
Returns a new instance of Licenses.
8 9 10 |
# File 'lib/pushover/licenses.rb', line 8 def initialize(client) @client = client end |
Instance Method Details
#assign(user: nil, email: nil, os: nil) ⇒ Response
Permanently assign one prepaid license credit to a user or e-mail address.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pushover/licenses.rb', line 24 def assign(user: nil, email: nil, os: nil) validate_recipient!(user, email) validate_os!(os) unless os.nil? body = { 'token' => @client.token } body['user'] = user unless user.nil? body['email'] = email unless email.nil? body['os'] = os unless os.nil? response = @client.connection.post( path: '/1/licenses/assign.json', body: Oj.dump(body), idempotent: false ) Response.create_from_excon_response(response) end |
#get ⇒ Response
Retrieve the application's available prepaid license credits.
14 15 16 17 18 19 20 |
# File 'lib/pushover/licenses.rb', line 14 def get response = @client.connection.get( path: '/1/licenses.json', query: { token: @client.token } ) Response.create_from_excon_response(response) end |