-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DNB-2915: custom journeys trigger (#29)
* 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
1 parent
230b7ea
commit e11b6d5
Showing
5 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |