plivo 4.61.2 → 4.61.4

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
  SHA1:
3
- metadata.gz: 2d294e80630afae4af42f280ea00df4e0058b5fa
4
- data.tar.gz: d612e7b7dd77e49abff26918acdadc2d6da7e59b
3
+ metadata.gz: 32adb2993a31e298a5739fdbf41b390c3cc16f68
4
+ data.tar.gz: 8b41028cfec6b74dfb46d316e7f70949392ffc46
5
5
  SHA512:
6
- metadata.gz: 37243d6d07e62e1266c85acc67c92c6a9c945951bf39d8e75e9b7b2eb5d2f6b18eae9520babd3daf34601656c26ea998b4b76a71c5b9e2c37ebedbb77cf0e3f7
7
- data.tar.gz: '08c1e507d18f6025b9137035fa21171d73ba11d4a4dff0b5f2074475420a300eedfc97f450e87c12431f00cac4bc066e5ba77dfd75181392af09d35cd5db5e29'
6
+ metadata.gz: eae1ac6873f457d79736b9f9492bab0085533f55c22d52d3dfea90c6de394d502f0fc8002cf6cf929e85ff308294820ed0c6761a0841194142b7931a6da10b63
7
+ data.tar.gz: '018aadb508be8ed0719d036dc7fa66476509a4a6b76cac184ed3f6f8843e91f5f792cc3e1f767c86061aaa4bfe30a3c7095ee996f3dfbb599c17406a29f35bc7'
data/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
  # Change Log
2
+
3
+ ## [4.61.4](https://github.com/plivo/plivo-ruby/tree/v4.61.4) (2025-02-25)
4
+ **Feature - Supporting parameter_name in WhatsApp Template .**
5
+ - Supporting `parameter_name` in WhatsApp Template .
6
+
7
+ ## [4.61.3](https://github.com/plivo/plivo-ruby/tree/v4.61.3) (2025-02-18)
8
+ **Feature - Throw GeoPermissionsError Exception on synchronous geo permissions error**
9
+
2
10
  ## [4.61.2](https://github.com/plivo/plivo-ruby/tree/v4.61.2)(2024-10-23)
3
11
  **Feature - FraudCheck param in Create, Get and List Session**
4
12
  - Support for the `fraud_check` parameter in sms verify session request
data/README.md CHANGED
@@ -9,7 +9,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'plivo', '>= 4.61.2'
12
+ gem 'plivo', '>= 4.61.4'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -246,6 +246,54 @@ puts response
246
246
  ```
247
247
  > Note: It is also possible to create and manage objects directly within the SDK for whatsapp, providing a structured approach to message creation.
248
248
 
249
+
250
+ ### Templated WhatsApp Messages With Named Parameter
251
+ This guide shows how to send templated WhatsApp messages with named parameters.
252
+
253
+ Example:
254
+ ```ruby
255
+ require "plivo"
256
+ include Plivo
257
+
258
+ api = RestClient.new("<auth_id>","<auth_token>")
259
+
260
+ template={
261
+ "name": "template_name",
262
+ "language": "en_US",
263
+ "components": [
264
+ {
265
+ "type": "header",
266
+ "parameters": [
267
+ {
268
+ "type": "text",
269
+ "parameter_name": "header_title",
270
+ "text": "WA-header"
271
+ }
272
+ ]
273
+ },
274
+ {
275
+ "type": "body",
276
+ "parameters": [
277
+ {
278
+ "type": "text",
279
+ "parameter_name": "user_name",
280
+ "text": "Saurabh"
281
+ }
282
+ ]
283
+ }
284
+ ]
285
+ }
286
+
287
+ response = api.messages.create(
288
+ src: "+14156667778",
289
+ dst:"+14156667777",
290
+ type:"whatsapp",
291
+ template:template,
292
+ url: "https://<yourdomain>.com/whatsapp_status/",
293
+ )
294
+ puts response
295
+ ```
296
+
249
297
  ### Free Form Messages
250
298
  Non-templated or Free Form WhatsApp messages can be sent as a reply to a user-initiated conversation (Service conversation) or if there is an existing ongoing conversation created previously by sending a templated WhatsApp message.
251
299
 
@@ -13,6 +13,7 @@ module Plivo
13
13
  # Base stuff
14
14
  attr_reader :headers, :auth_credentials
15
15
  @@voice_retry_count = 0
16
+ GEO_PERMISSION_ENDPOINTS = ['/Message/', '/Session/', '/Call/'].freeze
16
17
  def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout=5)
17
18
  configure_credentials(auth_id, auth_token)
18
19
  configure_proxies(proxy_options)
@@ -26,7 +27,7 @@ module Plivo
26
27
  end
27
28
 
28
29
  def process_response(method, response)
29
- handle_response_exceptions(response)
30
+ handle_response_exceptions(response, method)
30
31
  if method == 'DELETE'
31
32
  if !([200, 204].include? response[:status])
32
33
  raise Exceptions::PlivoRESTError, "Resource at #{response[:url]} "\
@@ -341,7 +342,7 @@ module Plivo
341
342
  response
342
343
  end
343
344
 
344
- def handle_response_exceptions(response)
345
+ def handle_response_exceptions(response, method)
345
346
  exception_mapping = {
346
347
  400 => [
347
348
  Exceptions::ValidationError,
@@ -373,6 +374,13 @@ module Plivo
373
374
  ]
374
375
  }
375
376
 
377
+ if response[:status] == 403 && method == 'POST' && GEO_PERMISSION_ENDPOINTS.any? { |endpoint| response[:url].to_s.end_with?(endpoint) }
378
+ exception_mapping[403] = [
379
+ Exceptions::GeoPermissionsError,
380
+ 'Geo-permission to the destination country is not enabled'
381
+ ]
382
+ end
383
+
376
384
  response_json = response[:body]
377
385
  return unless exception_mapping.key?(response[:status])
378
386
 
@@ -46,5 +46,9 @@ module Plivo
46
46
  ##
47
47
  # This will be raised when there is an authentication error
48
48
  ResourceNotFoundError = Class.new(PlivoRESTError)
49
+
50
+ ##
51
+ # This will be raised when the destination country is not enabled for sms/voice
52
+ GeoPermissionsError = Class.new(PlivoRESTError)
49
53
  end
50
54
  end
@@ -42,9 +42,9 @@ module Plivo
42
42
  end
43
43
 
44
44
  class Parameter
45
- attr_accessor :type, :text, :media, :payload, :currency, :date_time, :location
45
+ attr_accessor :type, :text, :media, :payload, :currency, :date_time, :location, :parameter_name
46
46
 
47
- def initialize(type: nil, text: nil, media: nil, payload: nil, currency: nil, date_time: nil, location: nil)
47
+ def initialize(type: nil, text: nil, media: nil, payload: nil, currency: nil, date_time: nil, location: nil, parameter_name: nil)
48
48
  @type = type
49
49
  @text = text
50
50
  @media = media
@@ -52,6 +52,7 @@ module Plivo
52
52
  @currency = currency
53
53
  @date_time = date_time
54
54
  @location = location
55
+ @parameter_name = parameter_name
55
56
  end
56
57
 
57
58
  def to_hash
@@ -62,7 +63,8 @@ module Plivo
62
63
  payload: @payload,
63
64
  currency: @currency&.to_hash,
64
65
  date_time: @date_time&.to_hash,
65
- location: @location&.to_hash
66
+ location: @location&.to_hash,
67
+ parameter_name: @parameter_name
66
68
  }.reject { |_, v| v.nil? }
67
69
  end
68
70
  end
data/lib/plivo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = "4.61.2".freeze
2
+ VERSION = "4.61.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.61.2
4
+ version: 4.61.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Plivo SDKs Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-23 00:00:00.000000000 Z
11
+ date: 2025-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday