Class: NgrokAPI::Services::BotUsersClient

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#clientObject (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

Parameters:

  • name (string) (defaults to: "")

    human-readable name used to identify the bot

  • active (boolean) (defaults to: nil)

    whether or not the bot is active

Returns:



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.

https://ngrok.com/docs/api#api-bot-users-create

Parameters:

  • name (string) (defaults to: "")

    human-readable name used to identify the bot

  • active (boolean) (defaults to: nil)

    whether or not the bot is active

Returns:



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

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



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.

https://ngrok.com/docs/api#api-bot-users-delete

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



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.

https://ngrok.com/docs/api#api-bot-users-get

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



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.

https://ngrok.com/docs/api#api-bot-users-get

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



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.

https://ngrok.com/docs/api#api-bot-users-list

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# 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.

https://ngrok.com/docs/api#api-bot-users-list

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/ngrokapi/services/bot_users_client.rb', line 161

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.

https://ngrok.com/docs/api#api-bot-users-update

Parameters:

  • id (string) (defaults to: "")
  • name (string) (defaults to: nil)

    human-readable name used to identify the bot

  • active (boolean) (defaults to: nil)

    whether or not the bot is active

Returns:



188
189
190
191
192
193
194
195
196
197
198
# File 'lib/ngrokapi/services/bot_users_client.rb', line 188

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.

https://ngrok.com/docs/api#api-bot-users-update

Parameters:

  • id (string) (defaults to: "")
  • name (string) (defaults to: nil)

    human-readable name used to identify the bot

  • active (boolean) (defaults to: nil)

    whether or not the bot is active

Returns:



210
211
212
213
214
215
216
217
218
219
220
# File 'lib/ngrokapi/services/bot_users_client.rb', line 210

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