customerio 5.4.0 → 5.5.0

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: 315eb46a7117b5e0408a57f896c49bf7336003db16439780d119ddc8e4015a1a
4
- data.tar.gz: 41ddd049e7978bb75e8c792dda18090e9ffe7e64a85079a2e4d56cbc097feb48
3
+ metadata.gz: db681e306c4d3d780852f5aa18546de96e63bde2149e7ea92e44e64f07ef2fdf
4
+ data.tar.gz: 695ef4db24d55f7da1ece9ac0f95e6813bd179db20fd15dc034b1a7660c9682f
5
5
  SHA512:
6
- metadata.gz: 895cf3b64c4f57ed636a2a80c7c356eb4387edd2f5c5c65d1d46b0a418330333f84f66407ef8d844adeeda13d6089ee00d3ce60d22790d17fa246622c291f9d9
7
- data.tar.gz: f213766bfb67f9ad8d570292816bba51e7c6863fbcc15d98e4f1f75d80953b00813e9c531c5b84d013f5531e23f4f623dbe77e5d054ea1ccc125608ef00a343b
6
+ metadata.gz: 630d232d3851e8abfaa1fa3c0806dda7496199f3d928d26e315d3b2c9bc234c9deeafff2c3d332b624664e355dcaaa54caf935337e8464073c08cfc4ad00a06a
7
+ data.tar.gz: 0d58478028485b1881e1996cfcc545bae0f33304698a84f2df2288a838ef8bc650e905b55ae80e51c84a7328930ba5bc4dc07051d551f28092a770143a47677e
@@ -56,6 +56,21 @@ module Customerio
56
56
  end
57
57
  end
58
58
 
59
+ def send_inbox_message(req)
60
+ raise "request must be an instance of Customerio::SendInboxMessageRequest" unless req.is_a?(Customerio::SendInboxMessageRequest)
61
+ response = @client.request(:post, send_inbox_message_path, req.message)
62
+
63
+ case response
64
+ when Net::HTTPSuccess then
65
+ JSON.parse(response.body)
66
+ when Net::HTTPBadRequest then
67
+ json = JSON.parse(response.body)
68
+ raise Customerio::InvalidResponse.new(response.code, json['meta']['error'], response)
69
+ else
70
+ raise InvalidResponse.new(response.code, response.body)
71
+ end
72
+ end
73
+
59
74
  private
60
75
 
61
76
  def send_email_path
@@ -69,5 +84,9 @@ module Customerio
69
84
  def send_sms_path
70
85
  "/v1/send/sms"
71
86
  end
87
+
88
+ def send_inbox_message_path
89
+ "/v1/send/inbox_message"
90
+ end
72
91
  end
73
92
  end
@@ -0,0 +1,31 @@
1
+ require 'base64'
2
+
3
+ module Customerio
4
+ class SendInboxMessageRequest
5
+ attr_reader :message
6
+
7
+ def initialize(opts)
8
+ @message = opts.delete_if { |field| invalid_field?(field) }
9
+ end
10
+
11
+ private
12
+
13
+ REQUIRED_FIELDS = %i(identifiers transactional_message_id)
14
+
15
+ OPTIONAL_FIELDS = %i(
16
+ message_data
17
+ disable_message_retention
18
+ queue_draft
19
+ send_at
20
+ language
21
+ )
22
+
23
+ def invalid_field?(field)
24
+ !REQUIRED_FIELDS.include?(field) && !OPTIONAL_FIELDS.include?(field)
25
+ end
26
+
27
+ def encode(data)
28
+ Base64.strict_encode64(data)
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module Customerio
2
- VERSION = "5.4.0"
2
+ VERSION = "5.5.0"
3
3
  end
data/lib/customerio.rb CHANGED
@@ -7,6 +7,7 @@ module Customerio
7
7
  require "customerio/requests/send_email_request"
8
8
  require "customerio/requests/send_push_request"
9
9
  require "customerio/requests/send_sms_request"
10
+ require "customerio/requests/send_inbox_message_request"
10
11
  require "customerio/api"
11
12
  require "customerio/param_encoder"
12
13
  end
@@ -311,4 +311,63 @@ describe Customerio::APIClient do
311
311
  )
312
312
  end
313
313
  end
314
+
315
+ describe "#send_inbox_message" do
316
+ it "sends a POST request to the /api/send/inbox_message path" do
317
+ req = Customerio::SendInboxMessageRequest.new(
318
+ identifiers: {
319
+ id: 'c1',
320
+ },
321
+ transactional_message_id: 1,
322
+ )
323
+
324
+ stub_request(:post, api_uri('/v1/send/inbox_message'))
325
+ .with(headers: request_headers, body: req.message)
326
+ .to_return(status: 200, body: { delivery_id: 1 }.to_json, headers: {})
327
+
328
+ client.send_inbox_message(req).should eq({ "delivery_id" => 1 })
329
+ end
330
+
331
+ it "handles validation failures (400)" do
332
+ req = Customerio::SendInboxMessageRequest.new(
333
+ identifiers: {
334
+ id: 'c1',
335
+ },
336
+ transactional_message_id: 1,
337
+ )
338
+
339
+ err_json = { meta: { error: "example error" } }.to_json
340
+
341
+ stub_request(:post, api_uri('/v1/send/inbox_message'))
342
+ .with(headers: request_headers, body: req.message)
343
+ .to_return(status: 400, body: err_json, headers: {})
344
+
345
+ lambda { client.send_inbox_message(req) }.should(
346
+ raise_error(Customerio::InvalidResponse) { |error|
347
+ error.message.should eq "example error"
348
+ error.code.should eq "400"
349
+ }
350
+ )
351
+ end
352
+
353
+ it "handles other failures (5xx)" do
354
+ req = Customerio::SendInboxMessageRequest.new(
355
+ identifiers: {
356
+ id: 'c1',
357
+ },
358
+ transactional_message_id: 1,
359
+ )
360
+
361
+ stub_request(:post, api_uri('/v1/send/inbox_message'))
362
+ .with(headers: request_headers, body: req.message)
363
+ .to_return(status: 500, body: "Server unavailable", headers: {})
364
+
365
+ lambda { client.send_inbox_message(req) }.should(
366
+ raise_error(Customerio::InvalidResponse) { |error|
367
+ error.message.should eq "Server unavailable"
368
+ error.code.should eq "500"
369
+ }
370
+ )
371
+ end
372
+ end
314
373
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customerio
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-13 00:00:00.000000000 Z
11
+ date: 2026-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -131,6 +131,7 @@ files:
131
131
  - lib/customerio/param_encoder.rb
132
132
  - lib/customerio/regions.rb
133
133
  - lib/customerio/requests/send_email_request.rb
134
+ - lib/customerio/requests/send_inbox_message_request.rb
134
135
  - lib/customerio/requests/send_push_request.rb
135
136
  - lib/customerio/requests/send_sms_request.rb
136
137
  - lib/customerio/version.rb