Module: MixinBot::API::Me

Included in:
MixinBot::API
Defined in:
lib/mixin_bot/api/me.rb

Instance Method Summary collapse

Instance Method Details

#friends(access_token: nil) ⇒ Object Also known as: read_friends



30
31
32
33
34
35
# File 'lib/mixin_bot/api/me.rb', line 30

def friends(access_token: nil)
  path = '/friends'
  access_token ||= access_token('GET', path, '')
  authorization = format('Bearer %<access_token>s', access_token: access_token)
  client.get(path, headers: { 'Authorization': authorization })
end

#me(access_token: nil) ⇒ Object Also known as: read_me



7
8
9
10
11
12
# File 'lib/mixin_bot/api/me.rb', line 7

def me(access_token: nil)
  path = '/me'
  access_token ||= access_token('GET', path, '')
  authorization = format('Bearer %<access_token>s', access_token: access_token)
  client.get(path, headers: { 'Authorization': authorization })
end

#update_me(full_name:, avatar_base64: nil, access_token: nil) ⇒ Object

developers.mixin.one/api/beta-mixin-message/update-profile/ avatar_base64: String: Base64 of image, supports format png, jpeg and gif, base64 image size > 1024.



18
19
20
21
22
23
24
25
26
27
# File 'lib/mixin_bot/api/me.rb', line 18

def update_me(full_name:, avatar_base64: nil, access_token: nil)
  path = '/me'
  payload = {
    full_name: full_name,
    avatar_base64: avatar_base64
  }
  access_token ||= access_token('POST', path, payload.to_json)
  authorization = format('Bearer %<access_token>s', access_token: access_token)
  client.post(path, headers: { 'Authorization': authorization }, json: payload)
end