blueticks 1.1.0 → 1.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: c36b093b9a84f49a90a4879b8c804dfbcbaef3facbce8e8e6d55d1a14977d9f7
4
- data.tar.gz: befdb19cf0c64e60eec29804a03b202987e28d26c9ca3502e1ec96591eca7ac2
3
+ metadata.gz: 37010a0e5754ece0536a64eaf63bb583785660221555232d49aa65f11a238f53
4
+ data.tar.gz: 1ad072d448a086103623fcff70cc5a43d90463f7c7694bf83ba612f558bd91ee
5
5
  SHA512:
6
- metadata.gz: e5004e9c6a34d01463d01d2e094ed9a86b18cd3b464ad8ca1796336fdb4d60b0f195fbdc976a69be862f672ce90c755f4a2f56231e86f633300e719ff20e4f6b
7
- data.tar.gz: 731a42669ae6dc5dd916edb3a12c6939ea5a3ab9dff35e269c622e25cd2c8e420b2d41d91854bafbf2fd2f743bab0eea52f2de68b1daf8502fd22c07c87d1667
6
+ metadata.gz: f4b7ffeaa70d42af62ab360dc07494c2501f1a337343424f7d097ceb325941ee31e05b4d239ba47bd6124d0eb90853b2fdffc462f0f81bb8c9969c0b08fa9ddf
7
+ data.tar.gz: 454e49416c6501c8f24250fc58a0a6ad4c974eb485525d1f3d54bd07316ac03ab30cb187ec343eba87a981316efd5da0fbf38b916f309701b5ef43dfd426e323
@@ -35,12 +35,14 @@ module Blueticks
35
35
 
36
36
  # Mark a chat as read (sends read receipts if enabled).
37
37
  def mark_read(chat_id)
38
- client.request("POST", "/v1/chats/#{chat_id}/mark_read")
38
+ data = client.request("POST", "/v1/chats/#{chat_id}/mark_read")
39
+ Types::OkResponse.from_hash(data)
39
40
  end
40
41
 
41
42
  # Open a chat on the engine (useful for UI-assisted workflows).
42
43
  def open(chat_id)
43
- client.request("POST", "/v1/chats/#{chat_id}/open")
44
+ data = client.request("POST", "/v1/chats/#{chat_id}/open")
45
+ Types::ChatRef.from_hash(data)
44
46
  end
45
47
 
46
48
  # List messages in a chat. `mode` is "latest" or "history".
@@ -57,38 +59,54 @@ module Blueticks
57
59
  Types::Page.from_hash(data, item_type: Types::ChatMessage)
58
60
  end
59
61
 
62
+ # Retrieve a single message in a chat by its key.
60
63
  def get_message(chat_id, key)
61
64
  data = client.request("GET", "/v1/chats/#{chat_id}/messages/#{key}")
62
65
  Types::ChatMessage.from_hash(data)
63
66
  end
64
67
 
68
+ # Get message delivery status (ack value: -1=error, 0=pending, 1=server, 2=device, 3=read, 4=played).
65
69
  def get_message_ack(chat_id, key)
66
- client.request("GET", "/v1/chats/#{chat_id}/messages/#{key}/ack")
70
+ data = client.request("GET", "/v1/chats/#{chat_id}/messages/#{key}/ack")
71
+ Types::MessageAck.from_hash(data)
67
72
  end
68
73
 
74
+ # React to a message. Pass an empty `emoji` string to remove a reaction.
69
75
  def react(chat_id, key, emoji:)
70
- client.request(
76
+ data = client.request(
71
77
  "POST",
72
78
  "/v1/chats/#{chat_id}/messages/#{key}/reactions",
73
79
  body: { "emoji" => emoji }
74
80
  )
81
+ Types::OkResponse.from_hash(data)
75
82
  end
76
83
 
84
+ # Ask the engine to pull older history from the connected phone.
77
85
  def load_older_messages(chat_id)
78
- client.request("POST", "/v1/chats/#{chat_id}/messages/load_older")
86
+ data = client.request("POST", "/v1/chats/#{chat_id}/messages/load_older")
87
+ Types::LoadOlderMessagesResponse.from_hash(data)
79
88
  end
80
89
 
90
+ # Get a hosted URL for the message media without inlining bytes.
91
+ def get_media_url(chat_id, key)
92
+ data = client.request("GET", "/v1/chats/#{chat_id}/messages/#{key}/media_url")
93
+ Types::MediaUrlResponse.from_hash(data)
94
+ end
95
+
96
+ # Fetch full media bytes (base64) for a message.
81
97
  def get_media(chat_id, key)
82
98
  data = client.request("GET", "/v1/chats/#{chat_id}/messages/#{key}/media")
83
99
  Types::ChatMedia.from_hash(data)
84
100
  end
85
101
 
102
+ # Batch get delivery status for up to 200 sent messages.
86
103
  def batch_message_acks(message_keys:)
87
- client.request(
104
+ data = client.request(
88
105
  "POST",
89
106
  "/v1/chats/message_acks",
90
107
  body: { "message_keys" => message_keys }
91
108
  )
109
+ Types::BatchMessageAcksResponse.from_hash(data)
92
110
  end
93
111
  end
94
112
  end
@@ -24,34 +24,48 @@ module Blueticks
24
24
  body = {}
25
25
  body["name"] = name unless name.nil?
26
26
  body["settings"] = settings unless settings.nil?
27
- client.request("PATCH", "/v1/groups/#{group_id}", body: body)
27
+ data = client.request("PATCH", "/v1/groups/#{group_id}", body: body)
28
+ Types::Group.from_hash(data)
28
29
  end
29
30
 
31
+ # Add a participant to the group by chat_id (JID) or +E.164 phone.
30
32
  def add_member(group_id, chat_id:)
31
- client.request("POST", "/v1/groups/#{group_id}/members", body: { "chat_id" => chat_id })
33
+ data = client.request("POST", "/v1/groups/#{group_id}/members",
34
+ body: { "chat_id" => chat_id })
35
+ Types::Group.from_hash(data)
32
36
  end
33
37
 
38
+ # Remove a participant from the group.
34
39
  def remove_member(group_id, chat_id)
35
- client.request("DELETE", "/v1/groups/#{group_id}/members/#{chat_id}")
40
+ data = client.request("DELETE", "/v1/groups/#{group_id}/members/#{chat_id}")
41
+ Types::Group.from_hash(data)
36
42
  end
37
43
 
44
+ # Grant admin privileges to a group member.
38
45
  def promote_admin(group_id, chat_id)
39
- client.request("POST", "/v1/groups/#{group_id}/members/#{chat_id}/admin")
46
+ data = client.request("POST", "/v1/groups/#{group_id}/members/#{chat_id}/admin")
47
+ Types::Group.from_hash(data)
40
48
  end
41
49
 
50
+ # Revoke admin privileges from a group member.
42
51
  def demote_admin(group_id, chat_id)
43
- client.request("DELETE", "/v1/groups/#{group_id}/members/#{chat_id}/admin")
52
+ data = client.request("DELETE", "/v1/groups/#{group_id}/members/#{chat_id}/admin")
53
+ Types::Group.from_hash(data)
44
54
  end
45
55
 
56
+ # Replace the group picture. `file_data_url` is a base64 data URL (PNG/JPEG, <=20 MiB).
46
57
  def set_picture(group_id, file_data_url:, file_name: nil, file_mime_type: nil)
47
58
  body = { "file_data_url" => file_data_url }
48
59
  body["file_name"] = file_name unless file_name.nil?
49
60
  body["file_mime_type"] = file_mime_type unless file_mime_type.nil?
50
- client.request("PUT", "/v1/groups/#{group_id}/picture", body: body)
61
+ data = client.request("PUT", "/v1/groups/#{group_id}/picture", body: body)
62
+ Types::Group.from_hash(data)
51
63
  end
52
64
 
65
+ # Leave the group as the authenticated identity. Idempotent (204).
53
66
  def leave(group_id)
54
67
  client.request("DELETE", "/v1/groups/#{group_id}/members/me")
68
+ nil
55
69
  end
56
70
  end
57
71
  end
@@ -47,5 +47,38 @@ module Blueticks
47
47
  field :original_quality, :boolean, nullable: true
48
48
  field :media_unavailable, [:enum, MEDIA_UNAVAILABLE_REASONS], nullable: true
49
49
  end
50
+
51
+ # Generic `{ "ok": true }` response envelope returned by acknowledged side-effects.
52
+ class OkResponse < Base
53
+ field :ok, :boolean
54
+ end
55
+
56
+ # `{ "chat_id": "..." }` envelope returned by /v1/chats/{chat_id}/open.
57
+ class ChatRef < Base
58
+ field :chat_id, :string
59
+ end
60
+
61
+ # `{ "ack": int|null }` envelope returned by .../messages/{key}/ack.
62
+ class MessageAck < Base
63
+ field :ack, :integer, nullable: true
64
+ end
65
+
66
+ # Response from POST /v1/chats/{chat_id}/messages/load_older.
67
+ class LoadOlderMessagesResponse < Base
68
+ field :total_messages, :integer, nullable: true
69
+ field :added, :integer, nullable: true
70
+ field :can_load_more, :boolean
71
+ end
72
+
73
+ # Response from GET /v1/chats/{chat_id}/messages/{key}/media_url.
74
+ class MediaUrlResponse < Base
75
+ field :url, :string, nullable: true
76
+ end
77
+
78
+ # Response from POST /v1/chats/message_acks.
79
+ # Server returns `{ "data": [free-form objects] }`; preserved as raw hashes.
80
+ class BatchMessageAcksResponse < Base
81
+ field :data, %i[array hash]
82
+ end
50
83
  end
51
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blueticks
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueticks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blueticks