selligent 0.1.1

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.
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selligent
4
+ class Client
5
+ # Implements the Status endpoint
6
+ #
7
+ # /Status
8
+ module Status
9
+ # Get the Selligent status
10
+ def status
11
+ get "#{root_url}/Status"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selligent
4
+ class Client
5
+ # Implements the stored procedures endpoints
6
+ #
7
+ # /organizations/:organization/storedprocedures/*
8
+ module StoredProcedures
9
+ # Get stored procedures defined in the given organization
10
+ #
11
+ # @param options [Hash] Additional options
12
+ # @option options [String] :filter Filter by type
13
+ # @option options [String] :search Search by name or description
14
+ def stored_procedures(options = {})
15
+ get "#{base_url}/storedprocedures", options
16
+ end
17
+
18
+ # Get details of a stored procedure
19
+ #
20
+ # @param name [String] Name of the stored procedure
21
+ def stored_procedure(name)
22
+ get "#{base_url}/storedprocedures/#{name}"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selligent
4
+ class Client
5
+ # Implements the task endpoints
6
+ #
7
+ # /organizations/:organization/tasks/*
8
+ module Tasks
9
+ # Get a collection of tasks
10
+ #
11
+ # @param options [Hash] Additional options
12
+ # @option options [String] :filter Filter by type
13
+ # @option options [String] :search Search by name, description or tags
14
+ # @option options [Integer] :skip Specify index to start form
15
+ # @option options [Integer] :take Specify number of tasks to take
16
+ def tasks(options = {})
17
+ get "#{base_url}/tasks", options
18
+ end
19
+
20
+ # Get task details by name
21
+ #
22
+ # @param name [String] The task name
23
+ def task(name)
24
+ get "#{base_url}/tasks/#{name}"
25
+ end
26
+
27
+ # Get task-actions by task name
28
+ #
29
+ # @param task_name [String] The task name
30
+ def task_actions(task_name)
31
+ get "#{base_url}/tasks/#{task_name}/actions"
32
+ end
33
+
34
+ # Disable a task
35
+ #
36
+ # @param name [String] The task name
37
+ def disable_task(name)
38
+ post "#{base_url}/tasks/#{name}/actions/disable"
39
+ end
40
+
41
+ # Enable a task
42
+ #
43
+ # @param name [String] The task name
44
+ def enable_task(name)
45
+ post "#{base_url}/tasks/#{name}/actions/enable"
46
+ end
47
+
48
+ # Run a task
49
+ #
50
+ # @param name [String] The task name
51
+ def run_task(name)
52
+ post "#{base_url}/tasks/#{name}/actions/run"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selligent
4
+ class Client
5
+ # Implements the transactional bulk endpoint
6
+ #
7
+ # /organizations/:organization/journeys/transcational/bulk/:name/send
8
+ module TransactionalBulk
9
+ # Trigger a bulk journey in a transactional way
10
+ #
11
+ # @params name [String] The name of the execution that should be sent
12
+ def send_transactional_bulk(name)
13
+ post "#{base_url}/journeys/transactional/bulk/#{name}/send"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selligent
4
+ class Client
5
+ # Implements the transactional endpoints
6
+ #
7
+ # /organizations/:organization/journeys/transactional/*
8
+ module Transactionals
9
+ # Returns a list of the transactional journeys defined on the organization.
10
+ def transactionals
11
+ get "#{base_url}/journeys/transactional"
12
+ end
13
+
14
+ # Returns information on the transactional journey with the given api name.
15
+ #
16
+ # @param api_name [String] The api name
17
+ def transactional(api_name)
18
+ get "#{base_url}/journeys/transactional/#{api_name}"
19
+ end
20
+
21
+ # Sends (multiple) transactional messages (email, mobile push, sms)
22
+ #
23
+ # The model has the following shape:
24
+ #
25
+ # {
26
+ # items: [
27
+ # recipient: "info@example.com",
28
+ # language: "EN',
29
+ # data: {},
30
+ # dtsdata: [
31
+ # {
32
+ # data_selection: "DTS1",
33
+ # content: [
34
+ # {
35
+ # id: "AB"
36
+ # },
37
+ # {
38
+ # id: "CD"
39
+ # }
40
+ # ]
41
+ # }
42
+ # ]
43
+ # ]
44
+ # }
45
+ #
46
+ # @param api_name [String] The name of the execution that should be sent
47
+ # @param model [Hash] The model containing the data that should be sent
48
+ # @option model [Array] :items The send requests
49
+ def send_transactional(api_name, model)
50
+ post "#{base_url}/journeys/transactional/#{api_name}/send", model
51
+ end
52
+
53
+ # Create and/or update a user profile and then trigger the transactional message
54
+ # with the given api-name on the given organization.
55
+ #
56
+ # The model has the following shape:
57
+ #
58
+ # {
59
+ # items: [
60
+ # {
61
+ # recipient: "fff",
62
+ # language: "EN",
63
+ # profile: [
64
+ # {
65
+ # scope: "MASTER",
66
+ # fields: {
67
+ # "Name": "John",
68
+ # "LastName": "Smith"
69
+ # }
70
+ # }
71
+ # ],
72
+ # data: {},
73
+ # dtsdata: [
74
+ # {
75
+ # data_selection: "DTS1",
76
+ # content: [
77
+ # {
78
+ # id: "AB"
79
+ # },
80
+ # {
81
+ # id: "CD"
82
+ # }
83
+ # ]
84
+ # }
85
+ # ]
86
+ # }
87
+ # ]
88
+ # }
89
+ #
90
+ # @param api_name [String] The name of the execution that should be sent
91
+ # @param model [Hash] The model containing the data that should be sent
92
+ # @option model [Array] :items The request bodies
93
+ def update_profile_and_send_transactional(api_name, model)
94
+ post "#{base_url}/journeys/transactional/shortcut/#{api_name}/updateProfileAndSend", model
95
+ end
96
+
97
+ # Returns a list of transactional-status-objects for the messages that correspond to
98
+ # the list of guids that is submitted, for the transactional journeys defined on the
99
+ # given organization.
100
+ #
101
+ # @param ids [Array<String>] The message identifiers
102
+ def transactionals_status(ids)
103
+ post "#{base_url}/journeys/transactional/status", ids
104
+ end
105
+
106
+ # Returns a transactional-status-object for the transactional journey with the given
107
+ # id on the given organization.
108
+ #
109
+ # @param id [String] The message id
110
+ def transactional_status(id)
111
+ get "#{base_url}/journeys/transactional/status/#{id}"
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selligent
4
+ # Configuration options for the Selligent Client.
5
+ class Configuration
6
+ attr_accessor :host, :api_key, :api_secret, :organization
7
+
8
+ def initialize(options = {})
9
+ @host = options[:host]
10
+ @api_key = options[:api_key]
11
+ @api_secret = options[:api_key]
12
+ @organization = options[:organization]
13
+ end
14
+
15
+ def inspect
16
+ inspected = super
17
+ inspected.gsub! @api_key, '*******' if @api_key
18
+ inspected.gsub! @api_secret, '*******' if @api_secret
19
+
20
+ inspected
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ module Selligent
7
+ # Network layer
8
+ module Connection
9
+ def get(url, options = {}, &block)
10
+ connection.get url, options, &block
11
+ end
12
+
13
+ def post(url, options = {}, &block)
14
+ connection.post url, options, &block
15
+ end
16
+
17
+ def put(url, options = {}, &block)
18
+ connection.put url, options, &block
19
+ end
20
+
21
+ def delete(url, options = {}, &block)
22
+ connection.delete url, options, &block
23
+ end
24
+
25
+ private
26
+
27
+ def connection
28
+ @connection ||= Faraday.new(url: config.host) do |conn|
29
+ conn.request :json
30
+ conn.request :selligent_auth
31
+
32
+ conn.response :json, parser_options: { symbolize_names: true }
33
+
34
+ conn.adapter Faraday.default_adapter
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+
5
+ require 'selligent'
6
+
7
+ module Selligent
8
+ module Middlewares
9
+ # Auth is a Faraday middleware
10
+ class Authorization < ::Faraday::Middleware
11
+ AUTH_HEADER = 'X-ApiKey'.freeze
12
+
13
+ def call(env)
14
+ env[:request_headers][AUTH_HEADER] = auth_header
15
+ @app.call(env)
16
+ end
17
+
18
+ def self.setup!
19
+ Faraday::Request.register_middleware selligent_auth: -> { self }
20
+ end
21
+
22
+ def auth_header
23
+ "#{Selligent.config.api_key}:#{Selligent.config.api_secret}"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Selligent
4
+ VERSION = '0.1.1'.freeze
5
+ end
data/selligent.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'selligent/version'
4
+
5
+ # Describe your gem and declare its dependencies:
6
+ Gem::Specification.new do |s|
7
+ s.name = 'selligent'
8
+ s.version = Selligent::VERSION
9
+ s.authors = ['Werner Hofstra']
10
+ s.email = ['w.hofstra@catawiki.nl']
11
+ s.homepage = 'https://github.com/catawiki/selligent'
12
+ s.summary = 'Selligent Ruby API client'
13
+ s.description = 'Provides access to the Selligent REST API'
14
+ s.license = 'proprietary'
15
+
16
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+
20
+ s.require_paths = ['lib']
21
+
22
+ s.add_development_dependency 'bundler', '~> 1.16'
23
+ s.add_dependency 'faraday'
24
+ s.add_dependency 'faraday_middleware'
25
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: selligent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Werner Hofstra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Provides access to the Selligent REST API
56
+ email:
57
+ - w.hofstra@catawiki.nl
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".circleci/config.yml"
63
+ - ".gitignore"
64
+ - ".rubocop.yml"
65
+ - Gemfile
66
+ - LICENSE
67
+ - README.md
68
+ - lib/selligent.rb
69
+ - lib/selligent/client.rb
70
+ - lib/selligent/client/content.rb
71
+ - lib/selligent/client/cumulio.rb
72
+ - lib/selligent/client/data.rb
73
+ - lib/selligent/client/journeys.rb
74
+ - lib/selligent/client/lists.rb
75
+ - lib/selligent/client/organizations.rb
76
+ - lib/selligent/client/single_batch.rb
77
+ - lib/selligent/client/status.rb
78
+ - lib/selligent/client/stored_procedures.rb
79
+ - lib/selligent/client/tasks.rb
80
+ - lib/selligent/client/transactional_bulk.rb
81
+ - lib/selligent/client/transactionals.rb
82
+ - lib/selligent/configuration.rb
83
+ - lib/selligent/connection.rb
84
+ - lib/selligent/middlewares/authorization.rb
85
+ - lib/selligent/version.rb
86
+ - selligent.gemspec
87
+ homepage: https://github.com/catawiki/selligent
88
+ licenses:
89
+ - proprietary
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.7.7
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Selligent Ruby API client
111
+ test_files: []