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.
- checksums.yaml +7 -0
- data/.circleci/config.yml +104 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +6 -0
- data/Gemfile +15 -0
- data/LICENSE +21 -0
- data/README.md +255 -0
- data/lib/selligent.rb +24 -0
- data/lib/selligent/client.rb +57 -0
- data/lib/selligent/client/content.rb +180 -0
- data/lib/selligent/client/cumulio.rb +64 -0
- data/lib/selligent/client/data.rb +145 -0
- data/lib/selligent/client/journeys.rb +15 -0
- data/lib/selligent/client/lists.rb +264 -0
- data/lib/selligent/client/organizations.rb +20 -0
- data/lib/selligent/client/single_batch.rb +250 -0
- data/lib/selligent/client/status.rb +15 -0
- data/lib/selligent/client/stored_procedures.rb +26 -0
- data/lib/selligent/client/tasks.rb +56 -0
- data/lib/selligent/client/transactional_bulk.rb +17 -0
- data/lib/selligent/client/transactionals.rb +115 -0
- data/lib/selligent/configuration.rb +23 -0
- data/lib/selligent/connection.rb +38 -0
- data/lib/selligent/middlewares/authorization.rb +27 -0
- data/lib/selligent/version.rb +5 -0
- data/selligent.gemspec +25 -0
- metadata +111 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'selligent/configuration'
|
4
|
+
require 'selligent/connection'
|
5
|
+
require 'selligent/client/content'
|
6
|
+
require 'selligent/client/cumulio'
|
7
|
+
require 'selligent/client/data'
|
8
|
+
require 'selligent/client/journeys'
|
9
|
+
require 'selligent/client/lists'
|
10
|
+
require 'selligent/client/organizations'
|
11
|
+
require 'selligent/client/single_batch'
|
12
|
+
require 'selligent/client/status'
|
13
|
+
require 'selligent/client/stored_procedures'
|
14
|
+
require 'selligent/client/tasks'
|
15
|
+
require 'selligent/client/transactional_bulk'
|
16
|
+
require 'selligent/client/transactionals'
|
17
|
+
require 'selligent/middlewares/authorization'
|
18
|
+
|
19
|
+
module Selligent
|
20
|
+
# The actual Selligent client
|
21
|
+
class Client
|
22
|
+
extend Forwardable
|
23
|
+
|
24
|
+
include Selligent::Connection
|
25
|
+
include Selligent::Client::Content
|
26
|
+
include Selligent::Client::Cumulio
|
27
|
+
include Selligent::Client::Data
|
28
|
+
include Selligent::Client::Journeys
|
29
|
+
include Selligent::Client::Lists
|
30
|
+
include Selligent::Client::Organizations
|
31
|
+
include Selligent::Client::SingleBatch
|
32
|
+
include Selligent::Client::Status
|
33
|
+
include Selligent::Client::StoredProcedures
|
34
|
+
include Selligent::Client::Tasks
|
35
|
+
include Selligent::Client::TransactionalBulk
|
36
|
+
include Selligent::Client::Transactionals
|
37
|
+
|
38
|
+
attr_reader :config
|
39
|
+
|
40
|
+
def initialize(options = {})
|
41
|
+
Selligent::Middlewares::Authorization.setup!
|
42
|
+
@config = Selligent::Configuration.new(options)
|
43
|
+
end
|
44
|
+
|
45
|
+
def configure
|
46
|
+
yield config
|
47
|
+
end
|
48
|
+
|
49
|
+
def root_url
|
50
|
+
'/Portal/Api'
|
51
|
+
end
|
52
|
+
|
53
|
+
def base_url
|
54
|
+
"#{root_url}/organizations/#{config.organization}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Selligent
|
4
|
+
class Client
|
5
|
+
# Implements the content endpoints
|
6
|
+
#
|
7
|
+
# /organizations/:organization/content/*
|
8
|
+
module Content
|
9
|
+
# Create simple (HTML only) single language email message content
|
10
|
+
#
|
11
|
+
# The model has the following shape:
|
12
|
+
#
|
13
|
+
# {
|
14
|
+
# "properties": {
|
15
|
+
# "name": "Message name",
|
16
|
+
# "description": "description",
|
17
|
+
# "api_name": "message_name",
|
18
|
+
# "tags": [
|
19
|
+
# "tag1",
|
20
|
+
# "tag2"
|
21
|
+
# ],
|
22
|
+
# "languages": [
|
23
|
+
# "en"
|
24
|
+
# ],
|
25
|
+
# "default_language": "en",
|
26
|
+
# "empty_language": "en",
|
27
|
+
# "audience_api_name": "my_audience"
|
28
|
+
# },
|
29
|
+
# "headers": {
|
30
|
+
# "en": [
|
31
|
+
# {
|
32
|
+
# "from_domain": "example.net",
|
33
|
+
# "from_alias": "info",
|
34
|
+
# "reply_email": "reply@example.net",
|
35
|
+
# "reply_alias": "Your reply alias",
|
36
|
+
# "to_alias": "John Doe",
|
37
|
+
# "preheader": "Put your preheader text here",
|
38
|
+
# "subject": "Put your subject here"
|
39
|
+
# }
|
40
|
+
# ]
|
41
|
+
# },
|
42
|
+
# "content": {
|
43
|
+
# "text": "Hello World!",
|
44
|
+
# "html": "<html><body>h1>Hello World!</h1></body></html>"
|
45
|
+
# }
|
46
|
+
# }
|
47
|
+
#
|
48
|
+
# @param model [Hash] The model
|
49
|
+
# @param params [Hash] The query parameters
|
50
|
+
# @option params [Boolean] :publish Indicate whether content should be published
|
51
|
+
def create_email(model, params = {})
|
52
|
+
post("#{base_url}/content/message", model) do |req|
|
53
|
+
req.params.merge!(params)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Create mobile push message content
|
58
|
+
#
|
59
|
+
# The model has the following shape:
|
60
|
+
#
|
61
|
+
# {
|
62
|
+
# "properties": {
|
63
|
+
# "name": "Message name",
|
64
|
+
# "description": "description",
|
65
|
+
# "api_name": "message_name",
|
66
|
+
# "tags": [
|
67
|
+
# "tag1",
|
68
|
+
# "tag2"
|
69
|
+
# ],
|
70
|
+
# "languages": [
|
71
|
+
# "en"
|
72
|
+
# ],
|
73
|
+
# "default_language": "en",
|
74
|
+
# "empty_language": "en",
|
75
|
+
# "audience_api_name": "my_audience"
|
76
|
+
# },
|
77
|
+
# "mobile_message_properties": {
|
78
|
+
# "distribution_type": "MobilePush",
|
79
|
+
# "custom_in_app_content": true,
|
80
|
+
# "in_app_content_type": "Text",
|
81
|
+
# "expiration_date": "2018-10-26T10:11:32.4188693+02:00"
|
82
|
+
# },
|
83
|
+
# "content": {
|
84
|
+
# "en": {
|
85
|
+
# "mobile_push": {
|
86
|
+
# "title": "MP Title en",
|
87
|
+
# "content": "MP Content en"
|
88
|
+
# },
|
89
|
+
# "in_app": {
|
90
|
+
# "title": "IA Title en",
|
91
|
+
# "content": {
|
92
|
+
# "text": "IA Content en",
|
93
|
+
# "url": "http://example.com"
|
94
|
+
# }
|
95
|
+
# }
|
96
|
+
# }
|
97
|
+
# }
|
98
|
+
# }
|
99
|
+
#
|
100
|
+
# @param model [Hash] The model
|
101
|
+
# @param params [Hash] The query parameters
|
102
|
+
# @option params [Boolean] :publish Indicate whether content should be published
|
103
|
+
def create_push_message(model, params = {})
|
104
|
+
post("#{base_url}/content/mobile", model) do |req|
|
105
|
+
req.params.merge!(params)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Create simple page content
|
110
|
+
#
|
111
|
+
# The model has the following shape:
|
112
|
+
#
|
113
|
+
# {
|
114
|
+
# "properties": {
|
115
|
+
# "name": "Message name",
|
116
|
+
# "description": "description",
|
117
|
+
# "api_name": "message_name",
|
118
|
+
# "tags": [
|
119
|
+
# "tag1",
|
120
|
+
# "tag2"
|
121
|
+
# ],
|
122
|
+
# "languages": [
|
123
|
+
# "en"
|
124
|
+
# ],
|
125
|
+
# "default_language": "en",
|
126
|
+
# "empty_language": "en",
|
127
|
+
# "audience_api_name": "my_audience"
|
128
|
+
# },
|
129
|
+
# "content": {
|
130
|
+
# "html": "<html><body><h1>Hello World!</h1></body></html>"
|
131
|
+
# }
|
132
|
+
# }
|
133
|
+
#
|
134
|
+
# @param model [Hash] The model
|
135
|
+
# @param params [Hash] The query parameters
|
136
|
+
# @option params [Boolean] :publish Indicate whether content should be published
|
137
|
+
def create_page(model, params = {})
|
138
|
+
post("#{base_url}/content/page", model) do |req|
|
139
|
+
req.params.merge!(params)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Create SMS content
|
144
|
+
#
|
145
|
+
# The model has the following shape:
|
146
|
+
#
|
147
|
+
# {
|
148
|
+
# "properties": {
|
149
|
+
# "name": "Message name",
|
150
|
+
# "description": "description",
|
151
|
+
# "api_name": "message_name",
|
152
|
+
# "tags": [
|
153
|
+
# "tag1",
|
154
|
+
# "tag2"
|
155
|
+
# ],
|
156
|
+
# "languages": [
|
157
|
+
# "en"
|
158
|
+
# ],
|
159
|
+
# "default_language": "en",
|
160
|
+
# "empty_language": "en",
|
161
|
+
# "audience_api_name": "my_audience"
|
162
|
+
# },
|
163
|
+
# "content": {
|
164
|
+
# "en": {
|
165
|
+
# "text": "Text"
|
166
|
+
# }
|
167
|
+
# }
|
168
|
+
# }
|
169
|
+
#
|
170
|
+
# @param model [Hash] The model
|
171
|
+
# @param params [Hash] The query parameters
|
172
|
+
# @option params [Boolean] :publish Indicate whether content should be published
|
173
|
+
def create_sms(model, params = {})
|
174
|
+
post("#{base_url}/content/sms", model) do |req|
|
175
|
+
req.params.merge!(params)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Selligent
|
4
|
+
class Client
|
5
|
+
# Implements the Cumulio endpoints
|
6
|
+
#
|
7
|
+
# /reporting/cumulio/:organization/{datasets, query}
|
8
|
+
module Cumulio
|
9
|
+
# Get datasets
|
10
|
+
def cumulio_datasets
|
11
|
+
get "#{root_url}/reporting/cumulio/#{config.organization}/datasets"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Run a cumulio query
|
15
|
+
#
|
16
|
+
# The model has the following shape:
|
17
|
+
#
|
18
|
+
# {
|
19
|
+
# "id": "string",
|
20
|
+
# "columns": [
|
21
|
+
# {
|
22
|
+
# "column_id": "string",
|
23
|
+
# "aggregation": "none",
|
24
|
+
# "level": "none"
|
25
|
+
# }
|
26
|
+
# ],
|
27
|
+
# "filters": [
|
28
|
+
# {
|
29
|
+
# "column_id": "string",
|
30
|
+
# "expression": "unknown",
|
31
|
+
# "value": [
|
32
|
+
# "string"
|
33
|
+
# ]
|
34
|
+
# }
|
35
|
+
# ],
|
36
|
+
# "user": {
|
37
|
+
# "id": "string",
|
38
|
+
# "name": "string",
|
39
|
+
# "email": "string",
|
40
|
+
# "authorization_id": "string",
|
41
|
+
# "metadata": {
|
42
|
+
# "tenant_id": "string",
|
43
|
+
# "organization": "string"
|
44
|
+
# }
|
45
|
+
# },
|
46
|
+
# "options": {
|
47
|
+
# "id": "string",
|
48
|
+
# "name": "string",
|
49
|
+
# "email": "string",
|
50
|
+
# "authorization_id": "string",
|
51
|
+
# "metadata": {
|
52
|
+
# "tenant_id": "string",
|
53
|
+
# "organization": "string"
|
54
|
+
# }
|
55
|
+
# }
|
56
|
+
# }
|
57
|
+
#
|
58
|
+
# @param model [Hash] The model
|
59
|
+
def cumulio_query(model)
|
60
|
+
post "#{root_url}/reporting/cumulio/#{config.organization}/query", model
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Selligent
|
4
|
+
class Client
|
5
|
+
# Implements the data endpoints
|
6
|
+
#
|
7
|
+
# /organizations/:organization/lists/data/*
|
8
|
+
module Data
|
9
|
+
# Deletes data from the list with the given api-name in the given organization
|
10
|
+
#
|
11
|
+
# @param api_name [String] The api name
|
12
|
+
# @param data [Array<Array>] The data
|
13
|
+
# @param params [Hash] Additional options
|
14
|
+
# @option params [String] :keyFields Comma-separated list of the key fields to delete records
|
15
|
+
# @option params [String] :fields Comma-separated list of the fields in data records
|
16
|
+
# @option params [String] :mode Data transfer mode (Sync or Stream)
|
17
|
+
# @option params [String] :errorHandling Error handling options
|
18
|
+
def delete_data(api_name, data, params = {})
|
19
|
+
delete("#{base_url}/lists/#{api_name}/data", params) do |req|
|
20
|
+
req.body = data.to_json
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Loads data into the list with the given api-name in the given organization
|
25
|
+
#
|
26
|
+
# @param api_name [String] The api name
|
27
|
+
# @param data [Array<Array>] The data
|
28
|
+
# @param params [Hash] Additional options
|
29
|
+
# @option params [String] :keyFields Comma-separated list of the key fields to delete records
|
30
|
+
# @option params [String] :fields Comma-separated list of the fields in data records
|
31
|
+
# @option params [String] :mode Data transfer mode (Sync or Stream)
|
32
|
+
# @option params [String] :deduplication De-duplication option during an import data
|
33
|
+
# @option params [String] :data_import_option Data import option during an import data
|
34
|
+
# @option params [String] :create_segment_name Segment name at the time of creation
|
35
|
+
# @option params [String] :create_segment_api_name Segment api name at the time of creation
|
36
|
+
# @option params [String] :errorHandling Error handling options
|
37
|
+
def load_data(api_name, data, params = {})
|
38
|
+
post("#{base_url}/lists/#{api_name}/data/load", data) do |req|
|
39
|
+
req.params.merge!(params)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Method to search for data records in a specific table
|
44
|
+
#
|
45
|
+
# The request has the following shape:
|
46
|
+
#
|
47
|
+
# {
|
48
|
+
# "fields": [
|
49
|
+
# "FIELD1",
|
50
|
+
# "FIELD2"
|
51
|
+
# ],
|
52
|
+
# "filters": [
|
53
|
+
# {
|
54
|
+
# "field_name": "FIELD1",
|
55
|
+
# "operator": "EqualTo",
|
56
|
+
# "field_value": "VALUE"
|
57
|
+
# }
|
58
|
+
# ],
|
59
|
+
# "skip": 20,
|
60
|
+
# "take": 20,
|
61
|
+
# "order_by": "FIELD2",
|
62
|
+
# "order_by_direction": "ASC"
|
63
|
+
# }
|
64
|
+
#
|
65
|
+
# @param api_name [String] The api name
|
66
|
+
# @param request [Hash] Details on the data that should be searched
|
67
|
+
# @param params [Hash] Additional options
|
68
|
+
# @option params [String] :mode Data transfer mode (Sync or Stream)
|
69
|
+
def search_data(api_name, request, params = {})
|
70
|
+
post("#{base_url}/lists/#{api_name}/data/search", request) do |req|
|
71
|
+
req.params.merge!(params)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Deletes data via json from the segment with the given segment-api-name in the list
|
76
|
+
# with the given api-name in the given organization
|
77
|
+
#
|
78
|
+
# @param api_name [String] The api name
|
79
|
+
# @param segment_api_name [String] API name of the segment
|
80
|
+
# @param data [Array<Array>] The data
|
81
|
+
# @param params [Hash] Additional options
|
82
|
+
# @option params [String] :keyFields Comma-separated list of the key fields to delete records
|
83
|
+
# @option params [String] :fields Comma-separated list of the fields in data records
|
84
|
+
# @option params [String] :mode Data transfer mode (Sync or Stream)
|
85
|
+
# @option params [String] :errorHandling Error handling options
|
86
|
+
def delete_data_from_segment(api_name, segment_api_name, data, params = {})
|
87
|
+
delete("#{base_url}/lists/#{api_name}/segments/#{segment_api_name}/data", params) do |req|
|
88
|
+
req.body = data.to_json
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Loads data into the segment with the given segment-api-name in the list
|
93
|
+
# with the given api-name in the given organization
|
94
|
+
#
|
95
|
+
# @param api_name [String] The api name
|
96
|
+
# @param segment_api_name [String] API name of the segment
|
97
|
+
# @param data [Array<Array>] The data
|
98
|
+
# @param params [Hash] Additional options
|
99
|
+
# @option params [String] :fields Comma-separated list of the fields in data records
|
100
|
+
# @option params [String] :mode Data transfer mode (Sync or Stream)
|
101
|
+
# @option params [String] :deduplication De-duplication option during an import data
|
102
|
+
# @option params [String] :errorHandling Error handling options
|
103
|
+
def load_data_into_segment(api_name, segment_api_name, data, params = {})
|
104
|
+
post("#{base_url}/lists/#{api_name}/segments/#{segment_api_name}/data/load", data) do |req|
|
105
|
+
req.params.merge!(params)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Method to search for data records within a segment of specific table
|
110
|
+
#
|
111
|
+
# The request has the following shape:
|
112
|
+
#
|
113
|
+
# {
|
114
|
+
# "fields": [
|
115
|
+
# "FIELD1",
|
116
|
+
# "FIELD2"
|
117
|
+
# ],
|
118
|
+
# "filters": [
|
119
|
+
# {
|
120
|
+
# "field_name": "FIELD1",
|
121
|
+
# "operator": "EqualTo",
|
122
|
+
# "field_value": "VALUE"
|
123
|
+
# }
|
124
|
+
# ],
|
125
|
+
# "skip": 20,
|
126
|
+
# "take": 20,
|
127
|
+
# "order_by": "FIELD2",
|
128
|
+
# "order_by_direction": "ASC"
|
129
|
+
# }
|
130
|
+
# @param api_name [String] The api name
|
131
|
+
# @param segment_api_name [String] API name of the segment
|
132
|
+
# @param request [Hash] details on the data that should be searched
|
133
|
+
# @param params [Hash] Additional options
|
134
|
+
# @option params [String] :mode Data transfer mode (Sync or Stream)
|
135
|
+
def search_data_within_segment(api_name, segment_api_name, request, params = {})
|
136
|
+
post(
|
137
|
+
"#{base_url}/lists/#{api_name}/segments/#{segment_api_name}/data/search",
|
138
|
+
request
|
139
|
+
) do |req|
|
140
|
+
req.params.merge!(params)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|