Class: NgrokAPI::Services::ServiceUsersClient
- Inherits:
-
Object
- Object
- NgrokAPI::Services::ServiceUsersClient
- Defined in:
- lib/ngrokapi/services/service_users_client.rb
Overview
Constant Summary collapse
- PATH =
The API path for the requests
'/service_users'- LIST_PROPERTY =
The List Property from the resulting API for list calls
'service_users'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(name: "", active: nil) ⇒ NgrokAPI::Models::ServiceUser
Create a new service user.
-
#create!(name: "", active: nil) ⇒ NgrokAPI::Models::ServiceUser
Create a new service user Throws an exception if API error.
-
#delete(id: "") ⇒ NgrokAPI::Models::Empty
Delete a service user by ID.
-
#delete!(id: "") ⇒ NgrokAPI::Models::Empty
Delete a service user by ID Throws an exception if API error.
-
#get(id: "") ⇒ NgrokAPI::Models::ServiceUser
Get the details of a Bot User by ID.
-
#get!(id: "") ⇒ NgrokAPI::Models::ServiceUser
Get the details of a Bot User by ID.
-
#initialize(client:) ⇒ ServiceUsersClient
constructor
A new instance of ServiceUsersClient.
-
#list(before_id: nil, limit: nil, filter: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all service users in this account.
-
#list!(before_id: nil, limit: nil, filter: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all service users in this account.
-
#update(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::ServiceUser
Update attributes of a service user by ID.
-
#update!(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::ServiceUser
Update attributes of a service user by ID.
Constructor Details
#initialize(client:) ⇒ ServiceUsersClient
Returns a new instance of ServiceUsersClient.
17 18 19 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 17 def initialize(client:) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
15 16 17 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 15 def client @client end |
Instance Method Details
#create(name: "", active: nil) ⇒ NgrokAPI::Models::ServiceUser
Create a new service user
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 29 def create(name: "", active: nil) path = '/service_users' replacements = { } data = {} data[:name] = name if name data[:active] = active if active result = @client.post(path % replacements, data: data) NgrokAPI::Models::ServiceUser.new(client: self, attrs: result) end |
#create!(name: "", active: nil) ⇒ NgrokAPI::Models::ServiceUser
Create a new service user Throws an exception if API error.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 49 def create!(name: "", active: nil) path = '/service_users' replacements = { } data = {} data[:name] = name if name data[:active] = active if active result = @client.post(path % replacements, data: data, danger: true) NgrokAPI::Models::ServiceUser.new(client: self, attrs: result) end |
#delete(id: "") ⇒ NgrokAPI::Models::Empty
Delete a service user by ID
67 68 69 70 71 72 73 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 67 def delete(id: "") path = '/service_users/%{id}' replacements = { id: id, } @client.delete(path % replacements) end |
#delete!(id: "") ⇒ NgrokAPI::Models::Empty
Delete a service user by ID Throws an exception if API error.
83 84 85 86 87 88 89 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 83 def delete!(id: "") path = '/service_users/%{id}' replacements = { id: id, } @client.delete(path % replacements, danger: true) end |
#get(id: "") ⇒ NgrokAPI::Models::ServiceUser
Get the details of a Bot User by ID.
98 99 100 101 102 103 104 105 106 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 98 def get(id: "") path = '/service_users/%{id}' replacements = { id: id, } data = {} result = @client.get(path % replacements, data: data) NgrokAPI::Models::ServiceUser.new(client: self, attrs: result) end |
#get!(id: "") ⇒ NgrokAPI::Models::ServiceUser
Get the details of a Bot User by ID. Throws an exception if API error.
116 117 118 119 120 121 122 123 124 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 116 def get!(id: "") path = '/service_users/%{id}' replacements = { id: id, } data = {} result = @client.get(path % replacements, data: data, danger: true) NgrokAPI::Models::ServiceUser.new(client: self, attrs: result) end |
#list(before_id: nil, limit: nil, filter: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all service users in this account.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 136 def list( before_id: nil, limit: nil, filter: nil, url: nil ) result = @client.list( before_id: before_id, limit: limit, filter: filter, url: url, path: PATH ) NgrokAPI::Models::Listable.new( client: self, attrs: result, list_property: LIST_PROPERTY, klass: NgrokAPI::Models::ServiceUser ) end |
#list!(before_id: nil, limit: nil, filter: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all service users in this account. Throws an exception if API error.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 169 def list!( before_id: nil, limit: nil, filter: nil, url: nil ) result = @client.list( before_id: before_id, limit: limit, filter: filter, danger: true, url: url, path: PATH ) NgrokAPI::Models::Listable.new( client: self, attrs: result, list_property: LIST_PROPERTY, klass: NgrokAPI::Models::ServiceUser, danger: true ) end |
#update(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::ServiceUser
Update attributes of a service user by ID.
202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 202 def update(id: "", name: nil, active: nil) path = '/service_users/%{id}' replacements = { id: id, } data = {} data[:name] = name if name data[:active] = active if active result = @client.patch(path % replacements, data: data) NgrokAPI::Models::ServiceUser.new(client: self, attrs: result) end |
#update!(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::ServiceUser
Update attributes of a service user by ID. Throws an exception if API error.
224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/ngrokapi/services/service_users_client.rb', line 224 def update!(id: "", name: nil, active: nil) path = '/service_users/%{id}' replacements = { id: id, } data = {} data[:name] = name if name data[:active] = active if active result = @client.patch(path % replacements, data: data, danger: true) NgrokAPI::Models::ServiceUser.new(client: self, attrs: result) end |