Class: NgrokAPI::Services::BotUsersClient
- Inherits:
-
Object
- Object
- NgrokAPI::Services::BotUsersClient
- Defined in:
- lib/ngrokapi/services/bot_users_client.rb
Overview
Constant Summary collapse
- PATH =
The API path for the requests
'/bot_users'
- LIST_PROPERTY =
The List Property from the resulting API for list calls
'bot_users'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(name: "", active: nil) ⇒ NgrokAPI::Models::BotUser
Create a new bot user.
-
#create!(name: "", active: nil) ⇒ NgrokAPI::Models::BotUser
Create a new bot user Throws an exception if API error.
-
#delete(id: "") ⇒ NgrokAPI::Models::Empty
Delete a bot user by ID.
-
#delete!(id: "") ⇒ NgrokAPI::Models::Empty
Delete a bot user by ID Throws an exception if API error.
-
#get(id: "") ⇒ NgrokAPI::Models::BotUser
Get the details of a Bot User by ID.
-
#get!(id: "") ⇒ NgrokAPI::Models::BotUser
Get the details of a Bot User by ID.
-
#initialize(client:) ⇒ BotUsersClient
constructor
A new instance of BotUsersClient.
-
#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all bot users in this account.
-
#list!(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all bot users in this account.
-
#update(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::BotUser
Update attributes of a bot user by ID.
-
#update!(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::BotUser
Update attributes of a bot user by ID.
Constructor Details
#initialize(client:) ⇒ BotUsersClient
Returns a new instance of BotUsersClient.
17 18 19 |
# File 'lib/ngrokapi/services/bot_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/bot_users_client.rb', line 15 def client @client end |
Instance Method Details
#create(name: "", active: nil) ⇒ NgrokAPI::Models::BotUser
Create a new bot user
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 29 def create(name: "", active: nil) path = '/bot_users' replacements = { } data = {} data[:name] = name if name data[:active] = active if active result = @client.post(path % replacements, data: data) NgrokAPI::Models::BotUser.new(client: self, attrs: result) end |
#create!(name: "", active: nil) ⇒ NgrokAPI::Models::BotUser
Create a new bot user Throws an exception if API error.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 49 def create!(name: "", active: nil) path = '/bot_users' replacements = { } data = {} data[:name] = name if name data[:active] = active if active result = @client.post(path % replacements, data: data, danger: true) NgrokAPI::Models::BotUser.new(client: self, attrs: result) end |
#delete(id: "") ⇒ NgrokAPI::Models::Empty
Delete a bot user by ID
67 68 69 70 71 72 73 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 67 def delete(id: "") path = '/bot_users/%{id}' replacements = { id: id, } @client.delete(path % replacements) end |
#delete!(id: "") ⇒ NgrokAPI::Models::Empty
Delete a bot user by ID Throws an exception if API error.
83 84 85 86 87 88 89 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 83 def delete!(id: "") path = '/bot_users/%{id}' replacements = { id: id, } @client.delete(path % replacements, danger: true) end |
#get(id: "") ⇒ NgrokAPI::Models::BotUser
Get the details of a Bot User by ID.
98 99 100 101 102 103 104 105 106 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 98 def get(id: "") path = '/bot_users/%{id}' replacements = { id: id, } data = {} result = @client.get(path % replacements, data: data) NgrokAPI::Models::BotUser.new(client: self, attrs: result) end |
#get!(id: "") ⇒ NgrokAPI::Models::BotUser
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/bot_users_client.rb', line 116 def get!(id: "") path = '/bot_users/%{id}' replacements = { id: id, } data = {} result = @client.get(path % replacements, data: data, danger: true) NgrokAPI::Models::BotUser.new(client: self, attrs: result) end |
#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all bot users in this account.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 135 def list( before_id: nil, limit: nil, url: nil ) result = @client.list( before_id: before_id, limit: limit, url: url, path: PATH ) NgrokAPI::Models::Listable.new( client: self, attrs: result, list_property: LIST_PROPERTY, klass: NgrokAPI::Models::BotUser ) end |
#list!(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all bot users in this account. Throws an exception if API error.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 165 def list!( before_id: nil, limit: nil, url: nil ) result = @client.list( before_id: before_id, limit: limit, danger: true, url: url, path: PATH ) NgrokAPI::Models::Listable.new( client: self, attrs: result, list_property: LIST_PROPERTY, klass: NgrokAPI::Models::BotUser, danger: true ) end |
#update(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::BotUser
Update attributes of a bot user by ID.
196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 196 def update(id: "", name: nil, active: nil) path = '/bot_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::BotUser.new(client: self, attrs: result) end |
#update!(id: "", name: nil, active: nil) ⇒ NgrokAPI::Models::BotUser
Update attributes of a bot user by ID. Throws an exception if API error.
218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/ngrokapi/services/bot_users_client.rb', line 218 def update!(id: "", name: nil, active: nil) path = '/bot_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::BotUser.new(client: self, attrs: result) end |