Class: Pcli::Services::Api
- Inherits:
-
Object
- Object
- Pcli::Services::Api
- Defined in:
- lib/pcli/services/api.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #auth(username, password, totp) ⇒ Object
- #change_me(payload) ⇒ Object
- #change_template(id, payload) ⇒ Object
- #change_user(id, payload) ⇒ Object
- #create_user(payload) ⇒ Object
- #info ⇒ Object
- #me ⇒ Object
- #remove_user(id) ⇒ Object
- #rotate_password ⇒ Object
- #rotate_totp ⇒ Object
- #send(request) ⇒ Object
- #templates ⇒ Object
- #users ⇒ Object
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/pcli/services/api.rb', line 7 def token @token end |
Instance Method Details
#auth(username, password, totp) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/pcli/services/api.rb', line 17 def auth(username, password, totp) send ApiRequest.new('admin/auth') .method(:post) .params( username: username, password: password, totp: totp ) end |
#change_me(payload) ⇒ Object
31 32 33 34 35 |
# File 'lib/pcli/services/api.rb', line 31 def change_me(payload) send authenticated(ApiRequest.new('admin/me') .method(:patch) .params(payload)) end |
#change_template(id, payload) ⇒ Object
69 70 71 72 73 |
# File 'lib/pcli/services/api.rb', line 69 def change_template(id, payload) send authenticated(ApiRequest.new("admin/templates/#{id}")) .method(:patch) .params(payload) end |
#change_user(id, payload) ⇒ Object
49 50 51 52 53 |
# File 'lib/pcli/services/api.rb', line 49 def change_user(id, payload) send authenticated(ApiRequest.new("admin/admins/#{id}")) .method(:patch) .params(payload) end |
#create_user(payload) ⇒ Object
55 56 57 58 59 |
# File 'lib/pcli/services/api.rb', line 55 def create_user(payload) send authenticated(ApiRequest.new('admin/admins')) .method(:post) .params(payload) end |
#info ⇒ Object
13 14 15 |
# File 'lib/pcli/services/api.rb', line 13 def info send ApiRequest.new('info') end |
#me ⇒ Object
27 28 29 |
# File 'lib/pcli/services/api.rb', line 27 def me send authenticated(ApiRequest.new('admin/me')) end |
#remove_user(id) ⇒ Object
61 62 63 |
# File 'lib/pcli/services/api.rb', line 61 def remove_user(id) send authenticated(ApiRequest.new("admin/admins/#{id}")).method(:delete) end |
#rotate_password ⇒ Object
37 38 39 |
# File 'lib/pcli/services/api.rb', line 37 def rotate_password send authenticated(ApiRequest.new('admin/me/password').method(:post)) end |
#rotate_totp ⇒ Object
41 42 43 |
# File 'lib/pcli/services/api.rb', line 41 def rotate_totp send authenticated(ApiRequest.new('admin/me/totp').method(:post)) end |
#send(request) ⇒ Object
9 10 11 |
# File 'lib/pcli/services/api.rb', line 9 def send(request) client.send(request) end |
#templates ⇒ Object
65 66 67 |
# File 'lib/pcli/services/api.rb', line 65 def templates send authenticated(ApiRequest.new('admin/templates')) end |
#users ⇒ Object
45 46 47 |
# File 'lib/pcli/services/api.rb', line 45 def users send authenticated(ApiRequest.new('admin/admins')) end |