Skip to content

Commit

Permalink
Merge pull request #236 from plivo/SMS-6589
Browse files Browse the repository at this point in the history
SMS-6589: Log Redaction
  • Loading branch information
Vishnukumarpg authored Feb 28, 2024
2 parents 97fc66d + 1aaff80 commit 39c1186
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [4.55.2](https://github.com/plivo/plivo-ruby/tree/v4.55.2) (2024-02-28)
**Feature - Log Redaction Enhancement**
- Added log attribute in GET and List MDR response
- Change log field from bool to string in send SMS

## [4.55.1](https://github.com/plivo/plivo-ruby/tree/v4.55.1) (2024-01-08)
**Feature - Added New Param 'type' for Speak Api**
- Added new param "type" for speak api
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
Add this line to your application's Gemfile:

```ruby
gem 'plivo', '>= 4.55.1'
gem 'plivo', '>= 4.55.2'
```

And then execute:
Expand Down
27 changes: 20 additions & 7 deletions lib/plivo/resources/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def to_s
carrier_fees: @carrier_fees,
conversation_id: @conversation_id,
conversation_origin: @conversation_origin,
conversation_expiration_timestamp: @conversation_expiration_timestamp
conversation_expiration_timestamp: @conversation_expiration_timestamp,
log: @log
}.to_s
end
end
Expand Down Expand Up @@ -146,9 +147,15 @@ def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil
end
end

if value.key?(:log) &&
valid_param?(:log, value[:log], [TrueClass, FalseClass], true)
params[:log] = value[:log]
if value.key?(:log)
log = value[:log]
if log.is_a?(TrueClass) || log.is_a?(FalseClass) # Check if log is boolean
params[:log] = log.to_s # Convert boolean to string
elsif log.is_a?(String) # Check if log is string
params[:log] = log
else
raise ArgumentError, "Invalid type for log parameter. Expected boolean or string."
end
end

if value.key?(:message_expiry) &&
Expand Down Expand Up @@ -285,9 +292,15 @@ def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil
params[:media_ids] = options[:media_ids]
end

if options.key?(:log) &&
valid_param?(:log, options[:log], [TrueClass, FalseClass], true)
params[:log] = options[:log]
if options.key?(:log)
log = options[:log]
if log.is_a?(TrueClass) || log.is_a?(FalseClass) # Check if log is boolean
params[:log] = log.to_s # Convert boolean to string
elsif log.is_a?(String) # Check if log is string
params[:log] = log
else
raise ArgumentError, "Invalid type for log parameter. Expected boolean or string."
end
end

if options.key?(:media_urls) &&
Expand Down
2 changes: 1 addition & 1 deletion lib/plivo/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Plivo
VERSION = "4.55.1".freeze
VERSION = "4.55.2".freeze
end
10 changes: 5 additions & 5 deletions spec/resource_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def to_json_list(list_object)
type: 'sms',
url: 'http://url.com',
method: 'POST',
log: true
log: "true"
))))
.to eql(JSON.parse(contents))
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Message/',
Expand All @@ -178,7 +178,7 @@ def to_json_list(list_object)
type: 'sms',
url: 'http://url.com',
method: 'POST',
log: true
log: "true"
})
end

Expand All @@ -194,7 +194,7 @@ def to_json_list(list_object)
type: 'sms',
url: 'http://url.com',
method: 'POST',
log: true
log: "true"
))))
.to eql(JSON.parse(contents))
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Message/',
Expand All @@ -207,7 +207,7 @@ def to_json_list(list_object)
type: 'sms',
url: 'http://url.com',
method: 'POST',
log: true
log: "true"
})
end

Expand All @@ -223,7 +223,7 @@ def to_json_list(list_object)
type: 'sms',
url: 'http://url.com',
method: 'POST',
log: true
log: "true"
)
end
.to raise_error(
Expand Down

0 comments on commit 39c1186

Please sign in to comment.