Skip to content

Commit

Permalink
DNB-2915: custom journeys trigger (#29)
Browse files Browse the repository at this point in the history
* DNB-2915: custom journeys trigger

* DNB-2915: ruby 2.7 tests

* DNB-2915: dropped required ruby version

* DNB-2915: cache fix

* DNB-2915: merge ruby jobs

* DNB-2915: fix version param

* DNB-2915: fix empty line

* DNB-2917: missing custom journey include

* DNB-2917: removed Gemfile.lock

* DNB-2917: circlci update

* DNB-2915: updated with master

* DNB-2915: comment update
  • Loading branch information
dobrodushny authored Sep 12, 2023
1 parent 230b7ea commit e11b6d5
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ Selligent.cumulio_datasets
Selligent.cumulio_query(model)
```

### Custom journey

```ruby
# Trigger custom journey. Reffer to the docs from CRM team for input.
Selligent.trigger_custom_journey(api_name, entrypoint_name, input)
```

### Status

```ruby
Expand Down
2 changes: 2 additions & 0 deletions lib/selligent/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'selligent/connection'
require 'selligent/client/content'
require 'selligent/client/cumulio'
require 'selligent/client/custom_journey'
require 'selligent/client/data'
require 'selligent/client/journeys'
require 'selligent/client/lists'
Expand All @@ -24,6 +25,7 @@ class Client
include Selligent::Connection
include Selligent::Client::Content
include Selligent::Client::Cumulio
include Selligent::Client::CustomJourney
include Selligent::Client::Data
include Selligent::Client::Journeys
include Selligent::Client::Lists
Expand Down
29 changes: 29 additions & 0 deletions lib/selligent/client/custom_journey.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Selligent
class Client
# Implements the custom journeys endpoints
#
# /organizations/:organization/journeys/custom/:api_name/entrypoints/:entrypoint_name/trigger
module CustomJourney
# Trigger execution of a custom journey
#
# The input has the following shape:
# Please note that parameter_values will differ per journey
#
# {
# "user_id": 0,
# "parameter_values": {
# "catawiki_id": Interger,
# "bid_timestamp": String
# }
# }
#
# @param user_id [Integer] Internal Selligent user ID. Sent as 0 by default.
# @param parameter_values [Hash] The input data in the format provided by the CRM team.
def trigger_custom_journey(api_name, entrypoint_name, input)
post "#{base_url}/journeys/custom/#{api_name}/entrypoints/#{entrypoint_name}/trigger", input
end
end
end
end
2 changes: 1 addition & 1 deletion lib/selligent/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Selligent
VERSION = '0.1.3'
VERSION = '0.1.4'
end
30 changes: 30 additions & 0 deletions spec/selligent/client/custom_journey_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Selligent::Client::CustomJourney do
include_context 'base_client'

describe '.custom_journey' do
let(:api_name) { 'new_journey' }
let(:entrypoint_name) { 'new_entrypoint' }
let(:input) do
{
user_id: 0,
parameter_values: {
catawiki_id: 123,
bid_timestamp: Time.now.to_s
}
}
end

it 'calls the correct endpoint' do
client.trigger_custom_journey(api_name, entrypoint_name, input)

expect(client).to have_received(:post).with(
"#{base_url}/journeys/custom/#{api_name}/entrypoints/#{entrypoint_name}/trigger",
input
)
end
end
end

0 comments on commit e11b6d5

Please sign in to comment.