Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

campaign import support #227

Merged
merged 9 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.51.0](https://github.com/plivo/plivo-ruby/tree/v4.51.0) (2023-10-16)
**Introducing campaign_source & import partner camapign API**
- New field campaign_source introduced
- Import partner campaign API added

## [4.50.0](https://github.com/plivo/plivo-ruby/tree/v4.50.0) (2023-10-13)
**Feature - WhatsApp message support**
- Added new params `template` and new message_type `whatsapp` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message)
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.50.0'
gem 'plivo', '>= 4.51.0'
```

And then execute:
Expand Down
18 changes: 16 additions & 2 deletions lib/plivo/resources/campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ def get(campaign_id)
##
# List all Campaign
# @param [Hash] options
# @option options [String] :brand
# @option options [String] :brand_id
# @option options [Status] :usecase
# @option options [String] :campaign_source
# @option options [Status] :limit
# @option options [Status] :offset
# @return [Hash]
def list(options=nil)
return perform_list_without_object if options.nil?

params = {}
%i[usecase brand limit offset].each do |param|
%i[usecase brand_id campaign_source limit offset].each do |param|
if options.key?(param) && valid_param?(param, options[param],
[String, Integer], true)
params[param] = options[param]
Expand Down Expand Up @@ -96,6 +97,19 @@ def update(campaign_id, options=nil)
perform_action_with_identifier(action, 'POST', options)
end
##

#import campaign
def import(options=nil)
valid_param?(:options, options, Hash, true)
if not options[:campaign_id]
raise_invalid_request("campaign_id must be provided")
end
if not options[:campaign_alias]
raise_invalid_request("campaign_alias must be provided")
end
action = 'Import'
perform_action_with_identifier(action, 'POST', options)
end
# campaign number link
#
def number_link(options=nil)
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.50.0".freeze
VERSION = "4.51.0".freeze
end
5 changes: 5 additions & 0 deletions spec/mocks/campaignImportResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"api_id": "2c6c5e16-090a-11ed-bb48-0242ac110004",
"campaign_id": "C1QGYD1",
"message": "Request to import campaign was received and is being processed."
}
18 changes: 18 additions & 0 deletions spec/resource_campaign_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,24 @@ def to_json_delete(obj)
method: 'DELETE',
data: nil)
end
it 'import campaign' do
contents = File.read(Dir.pwd + '/spec/mocks/campaignImportResponse.json')
mock(200, JSON.parse(contents))
response = to_json_create(@api.campaign
.import(options = {campaign_id:"C1QGYD1", campaign_alias:"plivo campaign"})
)

contents = JSON.parse(contents)

expect(JSON.parse(response))
.to eql(contents)
compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/Import/',
method: 'POST',
data: {
campaign_id: "C1QGYD1",
campaign_alias: "plivo campaign"
})
end
it 'delete campaign' do
contents = File.read(Dir.pwd + '/spec/mocks/campaignDeleteResponse.json')
mock(200, JSON.parse(contents))
Expand Down
Loading