Class: Bytom::AccessToken

Inherits:
Object
  • Object
show all
Defined in:
lib/bytom/api/access_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AccessToken

Returns a new instance of AccessToken.



6
7
8
# File 'lib/bytom/api/access_token.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#check_access_token(id:, secret:) ⇒ Object

Check access token is valid.

Parameters:

  • id (String)
  • secret (String)


47
48
49
50
51
52
53
# File 'lib/bytom/api/access_token.rb', line 47

def check_access_token(id: , secret:)
  params = {
      id: id,
      secret: secret
  }
  client.make_request('/check-access-token', 'post', params: params)
end

#create_access_token(id:, type: nil) ⇒ Object

Create access token, it provides basic access authentication for HTTP protocol, returns token contain username and password, they are separated by a colon.

Parameters:

  • id (String)

    token ID.

  • type (String) (defaults to: nil)

    optional type of token.



17
18
19
20
21
22
23
# File 'lib/bytom/api/access_token.rb', line 17

def create_access_token(id:, type: nil)
  params = {
      id: id,
      type: type
  }
  client.make_request('/create-access-token', 'post', params: params)
end

#delete_access_token(id:) ⇒ Object

Delete existed access token.

Parameters:

  • id (String)


37
38
39
# File 'lib/bytom/api/access_token.rb', line 37

def delete_access_token(id:)
  client.make_request('/delete-access-token', 'post', params: {id: id})
end

#list_access_tokensObject

Returns the list of all available access tokens.



28
29
30
# File 'lib/bytom/api/access_token.rb', line 28

def list_access_tokens
  client.make_request('/list-access-tokens', 'post', params: {})
end