blueticks 1.1.0 → 1.1.2
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 +4 -4
- data/lib/blueticks/resources/audiences.rb +3 -2
- data/lib/blueticks/resources/chats.rb +24 -6
- data/lib/blueticks/resources/groups.rb +20 -6
- data/lib/blueticks/resources/scheduled_messages.rb +4 -2
- data/lib/blueticks/resources/webhooks.rb +3 -2
- data/lib/blueticks/types/chats.rb +40 -0
- data/lib/blueticks/types/deleted_resource.rb +14 -0
- data/lib/blueticks/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19df800ede192ab6e262f3faeff874072d9c880466ad6d17cd5de461cdbf0b07
|
|
4
|
+
data.tar.gz: 25804da58032e239b22ef1027365fb05f12dd778633a542d52b41910eab3bffb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2a0ab6b4d585f6a93a51a0a13d55dda3e87d2499c32ae932c36a29448ce09e2a886e97c9d8c4b8ba6457ae63aa9de15d79d5a8e8530eaee2451ce02a9d1bd97
|
|
7
|
+
data.tar.gz: 05c7bcd1cc42f0604961fe157234a3dc1604304f93e276b57425504aea42453eaeb2f3e9da3c6b6f01350d1d7a33134d76cd8247c98f1c59928d45aea03becbc
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../base_resource"
|
|
4
4
|
require_relative "../types/audiences"
|
|
5
|
+
require_relative "../types/deleted_resource"
|
|
5
6
|
require_relative "../types/page"
|
|
6
7
|
|
|
7
8
|
module Blueticks
|
|
@@ -35,8 +36,8 @@ module Blueticks
|
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def delete(audience_id)
|
|
38
|
-
client.request("DELETE", "/v1/audiences/#{audience_id}")
|
|
39
|
-
|
|
39
|
+
data = client.request("DELETE", "/v1/audiences/#{audience_id}")
|
|
40
|
+
Types::DeletedResource.from_hash(data)
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
def append_contacts(audience_id, contacts:)
|
|
@@ -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",
|
|
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
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../base_resource"
|
|
4
|
+
require_relative "../types/deleted_resource"
|
|
4
5
|
require_relative "../types/scheduled_messages"
|
|
5
6
|
require_relative "../types/page"
|
|
6
7
|
|
|
@@ -41,10 +42,11 @@ module Blueticks
|
|
|
41
42
|
|
|
42
43
|
# Cancel scheduled message.
|
|
43
44
|
#
|
|
44
|
-
#
|
|
45
|
+
# Cancel a queued scheduled message before it fires. Soft-deletes the row
|
|
46
|
+
# (still queryable in audit logs). Returns the deleted ref.
|
|
45
47
|
def delete(id)
|
|
46
48
|
data = client.request("DELETE", "/v1/scheduled-messages/#{id}")
|
|
47
|
-
Types::
|
|
49
|
+
Types::DeletedResource.from_hash(data)
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../base_resource"
|
|
4
|
+
require_relative "../types/deleted_resource"
|
|
4
5
|
require_relative "../types/webhooks"
|
|
5
6
|
require_relative "../types/page"
|
|
6
7
|
|
|
@@ -39,8 +40,8 @@ module Blueticks
|
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def delete(webhook_id)
|
|
42
|
-
client.request("DELETE", "/v1/webhooks/#{webhook_id}")
|
|
43
|
-
|
|
43
|
+
data = client.request("DELETE", "/v1/webhooks/#{webhook_id}")
|
|
44
|
+
Types::DeletedResource.from_hash(data)
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
def rotate_secret(webhook_id)
|
|
@@ -47,5 +47,45 @@ 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
|
+
# Single entry in the BatchMessageAcksResponse `data` array.
|
|
79
|
+
# `{ "key": "<message key>", "ack": <int|null> }`.
|
|
80
|
+
class BatchMessageAckEntry < Base
|
|
81
|
+
field :key, :string
|
|
82
|
+
field :ack, :integer, nullable: true
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Response from POST /v1/chats/message_acks.
|
|
86
|
+
# `{ "data": [BatchMessageAckEntry, ...] }`.
|
|
87
|
+
class BatchMessageAcksResponse < Base
|
|
88
|
+
field :data, [:array, BatchMessageAckEntry]
|
|
89
|
+
end
|
|
50
90
|
end
|
|
51
91
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "base"
|
|
4
|
+
|
|
5
|
+
module Blueticks
|
|
6
|
+
module Types
|
|
7
|
+
# Response envelope returned by DELETE endpoints that confirm a soft-deletion.
|
|
8
|
+
# Shape: `{ "id": "<resource id>", "deleted": true }`.
|
|
9
|
+
class DeletedResource < Base
|
|
10
|
+
field :id, :string
|
|
11
|
+
field :deleted, [:enum, [true]]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/blueticks/version.rb
CHANGED
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.
|
|
4
|
+
version: 1.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Blueticks
|
|
@@ -85,6 +85,7 @@ files:
|
|
|
85
85
|
- lib/blueticks/types/campaigns.rb
|
|
86
86
|
- lib/blueticks/types/chats.rb
|
|
87
87
|
- lib/blueticks/types/contacts.rb
|
|
88
|
+
- lib/blueticks/types/deleted_resource.rb
|
|
88
89
|
- lib/blueticks/types/engines.rb
|
|
89
90
|
- lib/blueticks/types/groups.rb
|
|
90
91
|
- lib/blueticks/types/messages.rb
|