mixin_bot 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29930a091b973b490ea096e14f6344a0bc95f67b5023f081ac47fca36bc78adb
4
- data.tar.gz: eb58283464badcf4573f417ad8108e06216811bce36e0990bf10022d8e4802c8
3
+ metadata.gz: 844001cb92b3511f30cef15d4873763c9ff6f9d393d7ca8817afbad883ea4833
4
+ data.tar.gz: fb5e5e37129d3ccf01cb514fcf99c3539a9a73176d6c1d9ba5e3d35f48f55f8e
5
5
  SHA512:
6
- metadata.gz: 51e9e665540a634c383ee266d7b12ce67824c11a06a67fce43f66d3666a317d7c80e1ec974f7401ddb634230a73d0163702792876789c28210e91b8a43c68871
7
- data.tar.gz: 7e503ad0ca5116e99cf36423049b3017109e1d4c2ced08b1625630c55448cc5fbbe4047d0fb3c4ea4bf4abdfa7b7ffc89592671116e8d4d0739bfef9b05c1f52
6
+ metadata.gz: 6cc3caa449ef5bf0762c649e2be29b605b43e666d7ed651e7c01de6f590c88379b52510690fda86ceb411eaad62e2fc7a725c9eaea49d2a4979c5998eac63a02
7
+ data.tar.gz: 93cd21b8afd209f37e82f721eb99fa53abe30f435a78a701f34a9a9f259dff671e5544899e01cdded4ae5aef2682fd96ac1c1bd6027adcc5d6572b8cadba2d0b
@@ -4,9 +4,9 @@ module MixinBot
4
4
  class API
5
5
  module Me
6
6
  # https://developers.mixin.one/api/beta-mixin-message/read-profile/
7
- def read_me
7
+ def read_me(access_token = nil)
8
8
  path = '/me'
9
- access_token = access_token('GET', path, '')
9
+ access_token ||= access_token('GET', path, '')
10
10
  authorization = format('Bearer %<access_token>s', access_token: access_token)
11
11
  client.get(path, headers: { 'Authorization': authorization })
12
12
  end
@@ -14,37 +14,37 @@ module MixinBot
14
14
  # https://developers.mixin.one/api/beta-mixin-message/update-profile/
15
15
  # avatar_base64:
16
16
  # String: Base64 of image, supports format png, jpeg and gif, base64 image size > 1024.
17
- def update_me(full_name:, avatar_base64: nil)
17
+ def update_me(full_name:, avatar_base64: nil, access_token: nil)
18
18
  path = '/me'
19
19
  payload = {
20
20
  full_name: full_name,
21
21
  avatar_base64: avatar_base64
22
22
  }
23
- access_token = access_token('POST', path, payload.to_json)
23
+ access_token ||= access_token('POST', path, payload.to_json)
24
24
  authorization = format('Bearer %<access_token>s', access_token: access_token)
25
25
  client.post(path, headers: { 'Authorization': authorization }, json: payload)
26
26
  end
27
27
 
28
28
  # https://developers.mixin.one/api/alpha-mixin-network/read-assets/
29
- def read_assets
29
+ def read_assets(access_token = nil)
30
30
  path = '/assets'
31
- access_token = access_token('GET', path, '')
31
+ access_token ||= access_token('GET', path, '')
32
32
  authorization = format('Bearer %<access_token>s', access_token: access_token)
33
33
  client.get(path, headers: { 'Authorization': authorization })
34
34
  end
35
35
 
36
36
  # https://developers.mixin.one/api/alpha-mixin-network/read-asset/
37
- def read_asset(asset_id)
37
+ def read_asset(asset_id, access_token = nil)
38
38
  path = format('/assets/%<asset_id>s', asset_id: asset_id)
39
- access_token = access_token('GET', path, '')
39
+ access_token ||= access_token('GET', path, '')
40
40
  authorization = format('Bearer %<access_token>s', access_token: access_token)
41
41
  client.get(path, headers: { 'Authorization': authorization })
42
42
  end
43
43
 
44
44
  # https://developers.mixin.one/api/beta-mixin-message/friends/
45
- def read_friends
45
+ def read_friends(access_token = nil)
46
46
  path = '/friends'
47
- access_token = access_token('GET', path, '')
47
+ access_token ||= access_token('GET', path, '')
48
48
  authorization = format('Bearer %<access_token>s', access_token: access_token)
49
49
  client.get(path, headers: { 'Authorization': authorization })
50
50
  end
@@ -3,10 +3,11 @@
3
3
  module MixinBot
4
4
  class API
5
5
  module User
6
- def read_user(user_id, access_token = nil)
7
- # user_id: Mixin User Id
6
+ # https://developers.mixin.one/api/beta-mixin-message/read-user/
7
+ def read_user(user_id)
8
+ # user_id: Mixin User UUID
8
9
  path = format('/users/%<user_id>s', user_id: user_id)
9
- access_token ||= access_token('GET', path, '')
10
+ access_token = access_token('GET', path, '')
10
11
  authorization = format('Bearer %<access_token>s', access_token: access_token)
11
12
  client.get(path, headers: { 'Authorization': authorization })
12
13
  end
@@ -40,22 +41,22 @@ module MixinBot
40
41
 
41
42
  # https://developers.mixin.one/api/beta-mixin-message/search-user/
42
43
  # search by Mixin Id or Phone Number
43
- def search_user(query, access_token = nil)
44
+ def search_user(query)
44
45
  path = format('/search/%<query>s', query: query)
45
46
 
46
- access_token ||= access_token('GET', path, '')
47
+ access_token = access_token('GET', path, '')
47
48
  authorization = format('Bearer %<access_token>s', access_token: access_token)
48
49
  client.get(path, headers: { 'Authorization': authorization })
49
50
  end
50
51
 
51
52
  # https://developers.mixin.one/api/beta-mixin-message/read-users/
52
- def fetch_users(user_ids, access_token = nil)
53
+ def fetch_users(user_ids)
53
54
  # user_ids: a array of user_ids
54
55
  path = '/users/fetch'
55
56
  user_ids = [user_ids] if user_ids.is_a? String
56
57
  payload = user_ids
57
58
 
58
- access_token ||= access_token('POST', path, payload.to_json)
59
+ access_token = access_token('POST', path, payload.to_json)
59
60
  authorization = format('Bearer %<access_token>s', access_token: access_token)
60
61
  client.post(path, headers: { 'Authorization': authorization }, json: payload)
61
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MixinBot
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixin_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee