Module: Zanshin::SDK::Account

Included in:
Client
Defined in:
lib/zanshin/account.rb

Overview

Zanshin SDK Account

Instance Method Summary collapse

Instance Method Details

#accept_invite(invite_id) ⇒ Object

Accepts an invitation with the informed ID, it only works if the user accepting the invitation is the user that

received the invitation

[#reference](api.zanshin.tenchisecurity.com/#operation/acceptInviteById)

Parameters:

  • invite_id (UUID)

    of the invite

Returns:

  • an Object representing the organization of this invite


52
53
54
# File 'lib/zanshin/account.rb', line 52

def accept_invite(invite_id)
  @http.request('POST', "/me/invites/#{validate_uuid(invite_id)}/accept")
end

#create_api_key(name) ⇒ Object

Creates a new API key for the current logged user, API Keys can be used to interact with the zanshin api

directly on behalf of that user

[#reference](api.zanshin.tenchisecurity.com/#operation/createApiKeys)

Parameters:

  • name (String)

    of your new API key

Returns:

  • an Object representing the user api key


79
80
81
82
83
# File 'lib/zanshin/account.rb', line 79

def create_api_key(name)
  body = {}
  body['name'] = name
  @http.request('POST', '/me/apikeys', body)
end

#delete_api_key(api_key_id) ⇒ Object

Deletes a given API key by its id, it will only work if the informed ID belongs to the current logged user [#reference](api.zanshin.tenchisecurity.com/#operation/deleteApiKey)

Parameters:

  • api_key_id (UUID)

    of your new API key

Returns:

  • a Boolean with result


91
92
93
# File 'lib/zanshin/account.rb', line 91

def delete_api_key(api_key_id)
  @http.request('DELETE', "/me/apikeys/#{validate_uuid(api_key_id)}")
end

#get_invite(invite_id) ⇒ Object

Gets a specific invitation details, it only works if the invitation was made for the current logged user [#reference](api.zanshin.tenchisecurity.com/#operation/getInviteById)

Parameters:

  • invite_id (UUID)

    of the invite

Returns:

  • an Object representing the invite


41
42
43
# File 'lib/zanshin/account.rb', line 41

def get_invite(invite_id)
  @http.request('GET', "/me/invites/#{validate_uuid(invite_id)}")
end

#get_meObject

Returns the details of the user account that owns the API key used by this Connection instance [#reference](api.zanshin.tenchisecurity.com/#operation/getMe)

Returns:

  • an Object representing the user


15
16
17
# File 'lib/zanshin/account.rb', line 15

def get_me
  @http.request('GET', '/me')
end

#iter_api_keysObject

API keys Enumerator of current logged user [#reference](api.zanshin.tenchisecurity.com/#operation/getMyApiKeys)

Returns:

  • an API keys Enumerator object


64
65
66
67
68
69
70
# File 'lib/zanshin/account.rb', line 64

def iter_api_keys
  Enumerator.new do |yielder|
    @http.request('GET', '/me/apikeys').each do |e|
      yielder.yield e
    end
  end
end

#iter_invitesObject

Invites Enumerator of current logged user [#reference](api.zanshin.tenchisecurity.com/#operation/getInvites)

Returns:

  • an Invites Enumerator object


27
28
29
30
31
32
33
# File 'lib/zanshin/account.rb', line 27

def iter_invites
  Enumerator.new do |yielder|
    @http.request('GET', '/me/invites').each do |e|
      yielder.yield e
    end
  end
end