Class: IceJade::Quantum::Client
- Inherits:
-
ClientBase
- Object
- ClientBase
- IceJade::Quantum::Client
- Defined in:
- lib/ice_jade/quantum/client.rb
Overview
Quantum IM Webhook API client
Constant Summary collapse
- BASE_URL =
'https://imtwo.zdxlz.com/im-external/v1/webhook'
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key, base_url: BASE_URL) ⇒ Client
constructor
A new instance of Client.
-
#send_file(file_id) ⇒ Response
Send a file message.
-
#send_image(file_id, height:, width:) ⇒ Response
Send an image message.
-
#send_news(title, url, description: nil, pic_url: nil) ⇒ Response
Send a news / link card message.
-
#send_text(content, mention_all: false, mentioned_mobiles: nil) ⇒ Response
Send a text message.
-
#upload_and_send_file(path) ⇒ Response
Upload then immediately send a file.
-
#upload_and_send_image(path, height:, width:) ⇒ Response
Upload then immediately send an image.
-
#upload_file(path, filename: nil) ⇒ Response
Upload a generic file (type=2).
-
#upload_image(path, filename: nil) ⇒ Response
Upload an image file (type=1).
Constructor Details
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
11 12 13 |
# File 'lib/ice_jade/quantum/client.rb', line 11 def base_url @base_url end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/ice_jade/quantum/client.rb', line 11 def key @key end |
Instance Method Details
#send_file(file_id) ⇒ Response
Send a file message
47 48 49 50 |
# File 'lib/ice_jade/quantum/client.rb', line 47 def send_file(file_id) payload = Message.file(file_id) post_json('/send', payload) end |
#send_image(file_id, height:, width:) ⇒ Response
Send an image message
39 40 41 42 |
# File 'lib/ice_jade/quantum/client.rb', line 39 def send_image(file_id, height:, width:) payload = Message.image(file_id, height: height, width: width) post_json('/send', payload) end |
#send_news(title, url, description: nil, pic_url: nil) ⇒ Response
Send a news / link card message
58 59 60 61 |
# File 'lib/ice_jade/quantum/client.rb', line 58 def send_news(title, url, description: nil, pic_url: nil) payload = Message.news(title, url, description: description, pic_url: pic_url) post_json('/send', payload) end |
#send_text(content, mention_all: false, mentioned_mobiles: nil) ⇒ Response
Send a text message
29 30 31 32 |
# File 'lib/ice_jade/quantum/client.rb', line 29 def send_text(content, mention_all: false, mentioned_mobiles: nil) payload = Message.text(content, mention_all: mention_all, mentioned_mobiles: mentioned_mobiles) post_json('/send', payload) end |
#upload_and_send_file(path) ⇒ Response
Upload then immediately send a file
102 103 104 105 106 107 |
# File 'lib/ice_jade/quantum/client.rb', line 102 def upload_and_send_file(path) resp = upload_file(path) raise APIError, "Upload failed: #{resp.}" unless resp.success? send_file(resp.data['id']) end |
#upload_and_send_image(path, height:, width:) ⇒ Response
Upload then immediately send an image
92 93 94 95 96 97 |
# File 'lib/ice_jade/quantum/client.rb', line 92 def upload_and_send_image(path, height:, width:) resp = upload_image(path) raise APIError, "Upload failed: #{resp.}" unless resp.success? send_image(resp.data['id'], height: height, width: width) end |
#upload_file(path, filename: nil) ⇒ Response
Upload a generic file (type=2)
79 80 81 |
# File 'lib/ice_jade/quantum/client.rb', line 79 def upload_file(path, filename: nil) (path, type: 2, filename: filename) end |
#upload_image(path, filename: nil) ⇒ Response
Upload an image file (type=1)
71 72 73 |
# File 'lib/ice_jade/quantum/client.rb', line 71 def upload_image(path, filename: nil) (path, type: 1, filename: filename) end |