customerio 6.1.0 → 6.2.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: 901ad05a932585330dd1455f401b1a281b2a3390d2618d0623de62cdd4458988
4
- data.tar.gz: 93f962b44d651e177407a68de2ed555fd6fb0a711a3180afda823eee6973b5a7
3
+ metadata.gz: d7a5b0095c02a4c1b1a5cf0f9edf47a131d20d8f779620c4ddfe82298750ab7c
4
+ data.tar.gz: 9260b0c869b268a4c511c34fbb291ab82e2bb14a13a341a8b2482be31f50f869
5
5
  SHA512:
6
- metadata.gz: 9b787fe471290dd64811543d77f24bced641762d894824ffb1d43d671ed0179a6fb536477040bbceb797ca6ccb5f8c6164b085477dfea58db1cac311fd492be3
7
- data.tar.gz: e6c251d418be193333c26d07b78f78c61fa61cb3800f5e89dfef9a8c4680a3fcea9a67db09fa793a843172c6daf9ad800a222d6ce2bc0c9c2a2e99e1b633df21
6
+ metadata.gz: 7aed6bdc54c5f284ccbef64a7992c49cade462dca1513e7d31ee6496c7c884b1db0c8831ef8ff20a9223a3a8364dbcd703726424ce06d3ca4c2d82610d9da82c
7
+ data.tar.gz: 227a6869e02e98d8d3cdcfdcd3a8c928c7c114f7b7a92d72cd97612f2c3ed877e5d7ad4c160686e2c9e8c659b87b038b549d6e0aa844c9d28721ff8257f4767e
data/README.md CHANGED
@@ -439,6 +439,42 @@ rescue Customerio::InvalidResponse => e
439
439
  end
440
440
  ```
441
441
 
442
+ #### WhatsApp
443
+
444
+ Create a new `SendWhatsAppRequest` object containing:
445
+
446
+ * `transactional_message_id`: the ID or trigger name of the transactional message you want to send.
447
+ * an `identifiers` object containing the `id` or `email` of your recipient. If the profile does not exist, Customer.io creates it.
448
+
449
+ `to` is the WhatsApp number in E.164 format.
450
+
451
+ Use `send_whatsapp` referencing your request to send a transactional message. [Learn more about transactional messages and `SendWhatsAppRequest` properties](https://customer.io/docs/transactional-api).
452
+
453
+
454
+ ```ruby
455
+ require "customerio"
456
+
457
+ client = Customerio::APIClient.new("your API key", region: Customerio::Regions::US)
458
+
459
+ request = Customerio::SendWhatsAppRequest.new(
460
+ transactional_message_id: "3",
461
+ to: "+15551234567",
462
+ message_data: {
463
+ name: "Person",
464
+ },
465
+ identifiers: {
466
+ id: "2",
467
+ },
468
+ )
469
+
470
+ begin
471
+ response = client.send_whatsapp(request)
472
+ puts response
473
+ rescue Customerio::InvalidResponse => e
474
+ puts e.code, e.message
475
+ end
476
+ ```
477
+
442
478
  ### Trigger Broadcasts
443
479
 
444
480
  You can trigger [API-triggered broadcasts](https://customer.io/docs/api-triggered-broadcasts/) using the `APIClient`. Create a `TriggerBroadcastRequest` with the broadcast's numeric ID and optional audience/data parameters.
@@ -34,6 +34,12 @@ module Customerio
34
34
  deliver(send_sms_path, req.message)
35
35
  end
36
36
 
37
+ def send_whatsapp(req)
38
+ validate_request!(req, SendWhatsAppRequest)
39
+
40
+ deliver(send_whatsapp_path, req.message)
41
+ end
42
+
37
43
  def send_inbox_message(req)
38
44
  validate_request!(req, SendInboxMessageRequest)
39
45
 
@@ -86,6 +92,10 @@ module Customerio
86
92
  "/v1/send/sms"
87
93
  end
88
94
 
95
+ def send_whatsapp_path
96
+ "/v1/send/whatsapp"
97
+ end
98
+
89
99
  def send_inbox_message_path
90
100
  "/v1/send/inbox_message"
91
101
  end
@@ -13,6 +13,7 @@ module Customerio
13
13
  preheader
14
14
  from
15
15
  reply_to
16
+ cc
16
17
  bcc
17
18
  subject
18
19
  body
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "base64"
4
+
5
+ module Customerio
6
+ class SendWhatsAppRequest
7
+ REQUIRED_FIELDS = %i[identifiers transactional_message_id].freeze
8
+
9
+ OPTIONAL_FIELDS = %i[
10
+ message_data
11
+ to
12
+ disable_message_retention
13
+ send_to_unsubscribed
14
+ tracked
15
+ queue_draft
16
+ send_at
17
+ language
18
+ ].freeze
19
+
20
+ attr_reader :message
21
+
22
+ def initialize(opts)
23
+ @message = opts.select { |field, _value| valid_field?(field) }
24
+ @message[:attachments] ||= {}
25
+ end
26
+
27
+ def attach(name, data, encode: true)
28
+ raise ArgumentError, "attachment #{name} already exists" if @message[:attachments].key?(name)
29
+
30
+ @message[:attachments][name] = encode ? Base64.strict_encode64(data) : data
31
+ end
32
+
33
+ private
34
+
35
+ def valid_field?(field)
36
+ REQUIRED_FIELDS.include?(field) || OPTIONAL_FIELDS.include?(field)
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Customerio
4
- VERSION = "6.1.0"
4
+ VERSION = "6.2.0"
5
5
  end
data/lib/customerio.rb CHANGED
@@ -9,6 +9,7 @@ module Customerio
9
9
  require "customerio/requests/send_email_request"
10
10
  require "customerio/requests/send_push_request"
11
11
  require "customerio/requests/send_sms_request"
12
+ require "customerio/requests/send_whatsapp_request"
12
13
  require "customerio/requests/send_inbox_message_request"
13
14
  require "customerio/requests/send_in_app_request"
14
15
  require "customerio/requests/trigger_broadcast_request"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customerio
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allison
@@ -57,6 +57,7 @@ files:
57
57
  - lib/customerio/requests/send_inbox_message_request.rb
58
58
  - lib/customerio/requests/send_push_request.rb
59
59
  - lib/customerio/requests/send_sms_request.rb
60
+ - lib/customerio/requests/send_whatsapp_request.rb
60
61
  - lib/customerio/requests/trigger_broadcast_request.rb
61
62
  - lib/customerio/version.rb
62
63
  homepage: https://customer.io