Module: MixinBot::API::Me

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

Overview

API methods for bot profile management.

Provides methods to:

  • Retrieve bot profile information

  • Update bot profile (name, avatar)

  • List friends

  • Access Safe API profile

Instance Method Summary collapse

Instance Method Details

#friends(access_token: nil) ⇒ Array<Hash>

Retrieves the bot’s friend list.

Returns an array of users who have interacted with the bot and are in the bot’s contact list.

Examples:

friends = api.friends
friends.each do |friend|
  puts "#{friend['full_name']} (#{friend['user_id']})"
end

Parameters:

  • access_token (String, nil) (defaults to: nil)

    optional access token

Returns:

  • (Array<Hash>)

    array of user profiles

See Also:



86
87
88
89
# File 'lib/mixin_bot/api/me.rb', line 86

def friends(access_token: nil)
  path = '/friends'
  client.get path, access_token:
end

#me(access_token: nil) ⇒ Hash

Retrieves the bot’s profile information.

Returns detailed information about the bot including:

  • user_id

  • full_name

  • avatar_url

  • identity_number

  • phone

  • biography

  • created_at

Examples:

profile = api.me
puts profile['full_name']
puts profile['identity_number']

Parameters:

  • access_token (String, nil) (defaults to: nil)

    optional access token for authentication

Returns:

  • (Hash)

    the bot profile

See Also:



37
38
39
40
# File 'lib/mixin_bot/api/me.rb', line 37

def me(access_token: nil)
  path = '/me'
  client.get path, access_token:
end

#relationship(user_id:, action:, access_token: nil) ⇒ Object



125
126
127
128
# File 'lib/mixin_bot/api/me.rb', line 125

def relationship(user_id:, action:, access_token: nil)
  path = '/relationships'
  client.post path, user_id:, action:, access_token:
end

#safe_me(access_token: nil) ⇒ Hash Also known as: request_user_me

Retrieves the bot’s Safe API profile.

Returns Safe API-specific profile information including:

  • Safe wallet address

  • TIP signing key

  • Safe network status

Examples:

safe_profile = api.safe_me
puts safe_profile['user_id']

Parameters:

  • access_token (String, nil) (defaults to: nil)

    optional access token

Returns:

  • (Hash)

    the Safe API profile



106
107
108
109
# File 'lib/mixin_bot/api/me.rb', line 106

def safe_me(access_token: nil)
  path = '/safe/me'
  client.get path, access_token:
end

#update_me(**kwargs) ⇒ Hash

Updates the bot’s profile.

Allows updating:

  • full_name: the bot’s display name

  • avatar_base64: Base64-encoded avatar image (PNG, JPEG, or GIF, size > 1024 bytes)

Examples:

api.update_me(full_name: 'My Awesome Bot')
api.update_me(avatar_base64: Base64.strict_encode64(File.read('avatar.png')))

Parameters:

  • kwargs (Hash)

    update options

Options Hash (**kwargs):

  • :full_name (String)

    the new name for the bot

  • :avatar_base64 (String)

    Base64-encoded image data

  • :access_token (String)

    optional access token

Returns:

  • (Hash)

    the updated profile



59
60
61
62
63
64
65
66
67
# File 'lib/mixin_bot/api/me.rb', line 59

def update_me(**kwargs)
  path = '/me'
  payload = {
    full_name: kwargs[:full_name],
    avatar_base64: kwargs[:avatar_base64],
    access_token: kwargs[:access_token]
  }
  client.post path, **payload
end

#update_preferences(message_source: nil, conversation_source: nil, currency: nil, threshold: nil, access_token: nil) ⇒ Object Also known as: update_preference



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/mixin_bot/api/me.rb', line 112

def update_preferences(message_source: nil, conversation_source: nil, currency: nil, threshold: nil,
                       access_token: nil)
  path = '/me/preferences'
  payload = {
    receive_message_source: message_source,
    accept_conversation_source: conversation_source,
    fiat_currency: currency,
    transfer_notification_threshold: threshold
  }.compact
  client.post path, **payload, access_token:
end