exponea 0.1.9
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/.codeclimate.yml +16 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +54 -0
- data/.travis.yml +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +85 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/changelog.md +25 -0
- data/exponea.gemspec +38 -0
- data/lib/exponea.rb +23 -0
- data/lib/exponea/base_api.rb +52 -0
- data/lib/exponea/configuration.rb +11 -0
- data/lib/exponea/customers.rb +60 -0
- data/lib/exponea/events.rb +15 -0
- data/lib/exponea/version.rb +3 -0
- metadata +181 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2d8111631a0a3da6036f5362eb1b51d6ca7f94f764b7378b5b407fc9301e72fc
|
|
4
|
+
data.tar.gz: 9adbf7e19a2fabb6dbaf1407078f14561cdac62e956ac2768c3c0e6054059e86
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ac433b30f2e2f37e03b4eccb95a2c5e0e434c546edadb7451cf31f13c1be3c855f557c9651f3a3af333ee6be895bf0497a030792d498b25296e16e7d75b4d816
|
|
7
|
+
data.tar.gz: 366d90775525bab712c0a42b677844407333f2afe117f43dba25588d6373106113e072d592a49633c8ccb98b58a495df1dac8fb80614f993e36a393e119f7cd8
|
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
|
|
5
|
+
Layout/LineLength:
|
|
6
|
+
IgnoredPatterns: ['^#']
|
|
7
|
+
Max: 150
|
|
8
|
+
|
|
9
|
+
Style/FrozenStringLiteralComment:
|
|
10
|
+
Enabled: false
|
|
11
|
+
|
|
12
|
+
Metrics/BlockLength:
|
|
13
|
+
Exclude:
|
|
14
|
+
- 'spec/**/*'
|
|
15
|
+
- 'exponea.gemspec'
|
|
16
|
+
|
|
17
|
+
Layout/MultilineOperationIndentation:
|
|
18
|
+
EnforcedStyle: indented
|
|
19
|
+
|
|
20
|
+
Style/OptionalBooleanParameter:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
23
|
+
#Layout/HashAlignment:
|
|
24
|
+
# EnforcedColonStyle:
|
|
25
|
+
|
|
26
|
+
Metrics/AbcSize:
|
|
27
|
+
Max: 25
|
|
28
|
+
|
|
29
|
+
Style/Documentation:
|
|
30
|
+
Enabled: false
|
|
31
|
+
|
|
32
|
+
Layout/FirstArgumentIndentation:
|
|
33
|
+
EnforcedStyle: consistent
|
|
34
|
+
|
|
35
|
+
Metrics/CyclomaticComplexity:
|
|
36
|
+
Max: 10
|
|
37
|
+
|
|
38
|
+
Metrics/PerceivedComplexity:
|
|
39
|
+
Max: 10
|
|
40
|
+
|
|
41
|
+
Metrics/ClassLength:
|
|
42
|
+
Max: 200
|
|
43
|
+
|
|
44
|
+
Metrics/MethodLength:
|
|
45
|
+
Max: 15
|
|
46
|
+
|
|
47
|
+
Layout/MultilineMethodCallIndentation:
|
|
48
|
+
EnforcedStyle: indented_relative_to_receiver
|
|
49
|
+
|
|
50
|
+
Style/EmptyMethod:
|
|
51
|
+
EnforcedStyle: expanded
|
|
52
|
+
|
|
53
|
+
Style/DoubleNegation:
|
|
54
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
exponea (0.1.9)
|
|
5
|
+
faraday (~> 1)
|
|
6
|
+
faraday_middleware (~> 1)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
addressable (2.7.0)
|
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
+
ast (2.4.1)
|
|
14
|
+
codecov (0.1.21)
|
|
15
|
+
json
|
|
16
|
+
simplecov
|
|
17
|
+
crack (0.4.4)
|
|
18
|
+
diff-lcs (1.4.4)
|
|
19
|
+
docile (1.3.2)
|
|
20
|
+
faraday (1.1.0)
|
|
21
|
+
multipart-post (>= 1.2, < 3)
|
|
22
|
+
ruby2_keywords
|
|
23
|
+
faraday_middleware (1.0.0)
|
|
24
|
+
faraday (~> 1.0)
|
|
25
|
+
hashdiff (1.0.1)
|
|
26
|
+
json (2.3.1)
|
|
27
|
+
multipart-post (2.1.1)
|
|
28
|
+
parallel (1.20.1)
|
|
29
|
+
parser (2.7.2.0)
|
|
30
|
+
ast (~> 2.4.1)
|
|
31
|
+
public_suffix (4.0.6)
|
|
32
|
+
rainbow (3.0.0)
|
|
33
|
+
rake (13.0.1)
|
|
34
|
+
regexp_parser (2.0.0)
|
|
35
|
+
rexml (3.2.4)
|
|
36
|
+
rspec (3.9.0)
|
|
37
|
+
rspec-core (~> 3.9.0)
|
|
38
|
+
rspec-expectations (~> 3.9.0)
|
|
39
|
+
rspec-mocks (~> 3.9.0)
|
|
40
|
+
rspec-core (3.9.3)
|
|
41
|
+
rspec-support (~> 3.9.3)
|
|
42
|
+
rspec-expectations (3.9.2)
|
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
44
|
+
rspec-support (~> 3.9.0)
|
|
45
|
+
rspec-mocks (3.9.1)
|
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
+
rspec-support (~> 3.9.0)
|
|
48
|
+
rspec-support (3.9.3)
|
|
49
|
+
rubocop (0.93.1)
|
|
50
|
+
parallel (~> 1.10)
|
|
51
|
+
parser (>= 2.7.1.5)
|
|
52
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
53
|
+
regexp_parser (>= 1.8)
|
|
54
|
+
rexml
|
|
55
|
+
rubocop-ast (>= 0.6.0)
|
|
56
|
+
ruby-progressbar (~> 1.7)
|
|
57
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
58
|
+
rubocop-ast (1.3.0)
|
|
59
|
+
parser (>= 2.7.1.5)
|
|
60
|
+
ruby-progressbar (1.10.1)
|
|
61
|
+
ruby2_keywords (0.0.2)
|
|
62
|
+
simplecov (0.18.5)
|
|
63
|
+
docile (~> 1.1)
|
|
64
|
+
simplecov-html (~> 0.11)
|
|
65
|
+
simplecov-html (0.12.3)
|
|
66
|
+
unicode-display_width (1.7.0)
|
|
67
|
+
webmock (3.9.1)
|
|
68
|
+
addressable (>= 2.3.6)
|
|
69
|
+
crack (>= 0.3.2)
|
|
70
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
71
|
+
|
|
72
|
+
PLATFORMS
|
|
73
|
+
ruby
|
|
74
|
+
|
|
75
|
+
DEPENDENCIES
|
|
76
|
+
codecov (~> 0.1.10)
|
|
77
|
+
exponea!
|
|
78
|
+
rake (~> 13.0)
|
|
79
|
+
rspec (~> 3.6)
|
|
80
|
+
rubocop (~> 0.93.0)
|
|
81
|
+
simplecov (~> 0.18.5)
|
|
82
|
+
webmock (~> 3.9.0)
|
|
83
|
+
|
|
84
|
+
BUNDLED WITH
|
|
85
|
+
2.1.4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Lubomir Vnenk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[](https://travis-ci.com/lubosch/exponea)
|
|
2
|
+
[](https://codecov.io/gh/lubosch/exponea)
|
|
3
|
+
|
|
4
|
+
# Exponea
|
|
5
|
+
|
|
6
|
+
Gem for creating or updating customers in Exponea and triggering events in single or batch mode.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Add this line to your application's Gemfile:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'exponea'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
$ bundle install
|
|
19
|
+
|
|
20
|
+
Or install it yourself as:
|
|
21
|
+
|
|
22
|
+
$ gem install exponea
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
Exponea.configure do |config|
|
|
28
|
+
config.project = Rails.application.config_for(:exponea)[:project]
|
|
29
|
+
config.token = Rails.application.config_for(:exponea)[:token]
|
|
30
|
+
config.api_secret = Rails.application.config_for(:exponea)[:api_secret]
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Initialize `exponea.rb` with this settings:
|
|
35
|
+
- **project**: project id from exponea
|
|
36
|
+
- **token**: token generated from exponea
|
|
37
|
+
- **api_secret**(optional): secret API you can use in controllers to authorize requests from exponea to your app
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### Create or update customer
|
|
42
|
+
```
|
|
43
|
+
Exponea::Customers.update_properties(customer_id, properties, batch = false)
|
|
44
|
+
```
|
|
45
|
+
- **customer_id**: use either `registered` id or hash with one of your id
|
|
46
|
+
- **properties**: hash of properties to be updated
|
|
47
|
+
- **batch**: returns hash that can be sent as batch
|
|
48
|
+
|
|
49
|
+
### Add event
|
|
50
|
+
```
|
|
51
|
+
Exponea::Events.add_event(customer_id, event_type, properties = nil, batch = false, timestamp = nil)`
|
|
52
|
+
```
|
|
53
|
+
- **customer_id**: use either `registered` id or hash with one of your id
|
|
54
|
+
- **event_type**: event name defined in exponea
|
|
55
|
+
- **batch**: returns hash that can be sent as batch
|
|
56
|
+
- **timestamp**: modified timestamp of event if needed
|
|
57
|
+
|
|
58
|
+
### Batch events
|
|
59
|
+
```
|
|
60
|
+
Exponea::BaseApi.batch_commands(commands)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- **commands**: list of commands created with `batch = true`. They are sent in batches of 50 (exponea limitation)
|
|
64
|
+
|
|
65
|
+
## Development
|
|
66
|
+
|
|
67
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
68
|
+
|
|
69
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
|
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lubosch/exponea.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'exponea'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require 'irb'
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/changelog.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0
|
|
4
|
+
Basic api created
|
|
5
|
+
|
|
6
|
+
## 1.1
|
|
7
|
+
???
|
|
8
|
+
|
|
9
|
+
## 1.2
|
|
10
|
+
???
|
|
11
|
+
|
|
12
|
+
## 1.3
|
|
13
|
+
add support for multiple ids in add_event
|
|
14
|
+
|
|
15
|
+
## 1.6
|
|
16
|
+
Static analysis + readme
|
|
17
|
+
|
|
18
|
+
## 1.7
|
|
19
|
+
Bump faraday version
|
|
20
|
+
|
|
21
|
+
## 1.8
|
|
22
|
+
Better batch error handling
|
|
23
|
+
|
|
24
|
+
## 1.9
|
|
25
|
+
Metadata update
|
data/exponea.gemspec
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require_relative 'lib/exponea/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = 'exponea'
|
|
5
|
+
spec.version = Exponea::VERSION
|
|
6
|
+
spec.authors = ['Lubomir Vnenk']
|
|
7
|
+
spec.email = ['lubomir.vnenk@zoho.com']
|
|
8
|
+
|
|
9
|
+
spec.summary = 'Gem to integrate exponea into your app'
|
|
10
|
+
spec.description = 'Gem to integrate exponea into your app. Provides api for adding events and users, also bulk actions'
|
|
11
|
+
spec.homepage = 'https://github.com/lubosch/exponea'
|
|
12
|
+
spec.license = 'MIT'
|
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
|
14
|
+
|
|
15
|
+
spec.extra_rdoc_files = %w[README.md changelog.md]
|
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/lubosch/exponea'
|
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/lubosch/exponea/blob/master/changelog.md'
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
spec.bindir = 'exe'
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ['lib']
|
|
28
|
+
|
|
29
|
+
spec.add_dependency 'faraday', '~> 1'
|
|
30
|
+
spec.add_dependency 'faraday_middleware', '~> 1'
|
|
31
|
+
|
|
32
|
+
spec.add_development_dependency 'codecov', '~> 0.1.10'
|
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.6'
|
|
35
|
+
spec.add_development_dependency 'rubocop', '~> 0.93.0'
|
|
36
|
+
spec.add_development_dependency 'simplecov', '~> 0.18.5'
|
|
37
|
+
spec.add_development_dependency 'webmock', '~> 3.9.0'
|
|
38
|
+
end
|
data/lib/exponea.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'faraday'
|
|
2
|
+
require 'faraday_middleware'
|
|
3
|
+
|
|
4
|
+
require 'exponea/base_api'
|
|
5
|
+
require 'exponea/configuration'
|
|
6
|
+
require 'exponea/customers'
|
|
7
|
+
require 'exponea/events'
|
|
8
|
+
require 'exponea/version'
|
|
9
|
+
|
|
10
|
+
module Exponea
|
|
11
|
+
@configuration = Configuration.new
|
|
12
|
+
|
|
13
|
+
def self.config
|
|
14
|
+
@configuration
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.configure
|
|
18
|
+
yield(@configuration)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Error < StandardError
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module Exponea
|
|
2
|
+
class BaseApi
|
|
3
|
+
EXPONEA_URL = 'https://api.exponea.com'.freeze
|
|
4
|
+
|
|
5
|
+
def self.request(uri, method = 'POST', payload = nil)
|
|
6
|
+
client = Faraday.new(url: EXPONEA_URL) do |faraday|
|
|
7
|
+
faraday.request :json
|
|
8
|
+
faraday.response :json
|
|
9
|
+
|
|
10
|
+
faraday.adapter Faraday.default_adapter
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
response = client.send(method.downcase.to_sym) do |request|
|
|
14
|
+
request.headers['authorization'] = "Basic #{Exponea.config.token}"
|
|
15
|
+
request.url(uri)
|
|
16
|
+
request.body = payload
|
|
17
|
+
end
|
|
18
|
+
response.body
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.batch_commands(commands)
|
|
22
|
+
responses = []
|
|
23
|
+
commands.each_slice(50) do |command_batch|
|
|
24
|
+
path = "track/v2/projects/#{Exponea.config.project}/batch"
|
|
25
|
+
payload = { commands: command_batch }
|
|
26
|
+
response = post(path, payload)
|
|
27
|
+
response = post(path, payload) unless response['success'] # retry if exponea failed for some reason
|
|
28
|
+
|
|
29
|
+
next unless response['success']
|
|
30
|
+
|
|
31
|
+
response['results'].each { |result| responses.push(response['time'] ? result['time'] : result['success']) }
|
|
32
|
+
end
|
|
33
|
+
responses
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.get(path)
|
|
37
|
+
request(path, 'GET')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.post(path, payload)
|
|
41
|
+
request(path, 'POST', payload)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.delete(path, payload)
|
|
45
|
+
request(path, 'DELETE', payload)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.put(path, payload)
|
|
49
|
+
request(path, 'PUT', payload)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module Exponea
|
|
2
|
+
class Customers < BaseApi
|
|
3
|
+
def self.update_properties(customer_id, properties, batch = false)
|
|
4
|
+
customer_ids = customer_id.is_a?(Hash) ? customer_id : { registered: customer_id }
|
|
5
|
+
payload = { customer_ids: customer_ids, properties: properties }
|
|
6
|
+
return { name: 'customers', data: payload } if batch
|
|
7
|
+
|
|
8
|
+
path = "/track/v2/projects/#{Exponea.config.project}/customers"
|
|
9
|
+
post(path, payload)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# def self.customer(ids)
|
|
13
|
+
# path = "/data/v2/projects/#{Exponea.config.project}/customers/export-one"
|
|
14
|
+
# payload = { customer_ids: ids }
|
|
15
|
+
# post(path, payload)
|
|
16
|
+
# end
|
|
17
|
+
|
|
18
|
+
# def customer_consents(ids, consents)
|
|
19
|
+
# path = "/data/v2/projects/#{Exponea.config.project}/customers/attributes"
|
|
20
|
+
# payload = { customer_ids: ids,
|
|
21
|
+
# attributes: consents.map { |consent| { type: 'consent', category: consent } } }
|
|
22
|
+
# post(path, payload)
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
# def customer_attributes(customer_ids, properties: [], segmentations: [], ids: [], expressions: [], aggregations: [], predictions: [])
|
|
26
|
+
# path = "/data/v2/projects/#{Exponea.config.project}/customers/attributes"
|
|
27
|
+
# payload = {
|
|
28
|
+
# customer_ids: customer_ids,
|
|
29
|
+
# attributes:
|
|
30
|
+
# properties.map { |property| { type: 'property', property: property } } +
|
|
31
|
+
# segmentations.map { |segment| { type: 'segmentation', id: segment } } +
|
|
32
|
+
# ids.map { |id| { type: 'id', id: id } } +
|
|
33
|
+
# expressions.map { |expression| { type: 'expression', id: expression } } +
|
|
34
|
+
# aggregations.map { |aggregate| { type: 'aggregate', id: aggregate } } +
|
|
35
|
+
# predictions.map { |prediction| { type: 'prediction', id: prediction } }
|
|
36
|
+
# }
|
|
37
|
+
# post(path, payload)
|
|
38
|
+
# end
|
|
39
|
+
|
|
40
|
+
# def self.customers
|
|
41
|
+
# path = "/data/v2/projects/#{Exponea.config.project}/customers/export"
|
|
42
|
+
# payload = { format: 'native_json' }
|
|
43
|
+
# users = []
|
|
44
|
+
# response = post(path, payload)
|
|
45
|
+
# response['fields'].filter {|field| field['type'] == 'id'}
|
|
46
|
+
# end
|
|
47
|
+
|
|
48
|
+
# def self.events(customer_ids, event_types)
|
|
49
|
+
# path = "/data/v2/projects/#{Exponea.config.project}/customers/events"
|
|
50
|
+
# payload = { customer_ids: customer_ids, event_types: event_types }
|
|
51
|
+
# response = post(path, payload)
|
|
52
|
+
# end
|
|
53
|
+
|
|
54
|
+
# def self.anonymize_customer(customer_ids)
|
|
55
|
+
# path = "/data/v2/projects/#{Exponea.config.project}/customers/anonymize"
|
|
56
|
+
# payload = { customer_ids: customer_ids }
|
|
57
|
+
# response = post(path, payload)
|
|
58
|
+
# end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Exponea
|
|
2
|
+
class Events < BaseApi
|
|
3
|
+
def self.add_event(customer_id, event_type, properties = nil, batch = false, timestamp = nil)
|
|
4
|
+
customer_ids = customer_id.is_a?(Hash) ? customer_id : { registered: customer_id }
|
|
5
|
+
payload = { customer_ids: customer_ids,
|
|
6
|
+
properties: properties,
|
|
7
|
+
event_type: event_type }
|
|
8
|
+
payload = payload.merge(timestamp: timestamp.to_i) if timestamp
|
|
9
|
+
return { name: 'customers/events', data: payload } if batch
|
|
10
|
+
|
|
11
|
+
path = "/track/v2/projects/#{Exponea.config.project}/customers/events"
|
|
12
|
+
post(path, payload)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: exponea
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.9
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Lubomir Vnenk
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: faraday
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: faraday_middleware
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: codecov
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.1.10
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.1.10
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '13.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '13.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.6'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.6'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.93.0
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.93.0
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: simplecov
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 0.18.5
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 0.18.5
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: webmock
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 3.9.0
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 3.9.0
|
|
125
|
+
description: Gem to integrate exponea into your app. Provides api for adding events
|
|
126
|
+
and users, also bulk actions
|
|
127
|
+
email:
|
|
128
|
+
- lubomir.vnenk@zoho.com
|
|
129
|
+
executables: []
|
|
130
|
+
extensions: []
|
|
131
|
+
extra_rdoc_files:
|
|
132
|
+
- README.md
|
|
133
|
+
- changelog.md
|
|
134
|
+
files:
|
|
135
|
+
- ".codeclimate.yml"
|
|
136
|
+
- ".gitignore"
|
|
137
|
+
- ".rspec"
|
|
138
|
+
- ".rubocop.yml"
|
|
139
|
+
- ".travis.yml"
|
|
140
|
+
- Gemfile
|
|
141
|
+
- Gemfile.lock
|
|
142
|
+
- LICENSE.txt
|
|
143
|
+
- README.md
|
|
144
|
+
- Rakefile
|
|
145
|
+
- bin/console
|
|
146
|
+
- bin/setup
|
|
147
|
+
- changelog.md
|
|
148
|
+
- exponea.gemspec
|
|
149
|
+
- lib/exponea.rb
|
|
150
|
+
- lib/exponea/base_api.rb
|
|
151
|
+
- lib/exponea/configuration.rb
|
|
152
|
+
- lib/exponea/customers.rb
|
|
153
|
+
- lib/exponea/events.rb
|
|
154
|
+
- lib/exponea/version.rb
|
|
155
|
+
homepage: https://github.com/lubosch/exponea
|
|
156
|
+
licenses:
|
|
157
|
+
- MIT
|
|
158
|
+
metadata:
|
|
159
|
+
homepage_uri: https://github.com/lubosch/exponea
|
|
160
|
+
source_code_uri: https://github.com/lubosch/exponea
|
|
161
|
+
changelog_uri: https://github.com/lubosch/exponea/blob/master/changelog.md
|
|
162
|
+
post_install_message:
|
|
163
|
+
rdoc_options: []
|
|
164
|
+
require_paths:
|
|
165
|
+
- lib
|
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
|
+
requirements:
|
|
168
|
+
- - ">="
|
|
169
|
+
- !ruby/object:Gem::Version
|
|
170
|
+
version: 2.4.0
|
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
|
+
requirements:
|
|
173
|
+
- - ">="
|
|
174
|
+
- !ruby/object:Gem::Version
|
|
175
|
+
version: '0'
|
|
176
|
+
requirements: []
|
|
177
|
+
rubygems_version: 3.1.4
|
|
178
|
+
signing_key:
|
|
179
|
+
specification_version: 4
|
|
180
|
+
summary: Gem to integrate exponea into your app
|
|
181
|
+
test_files: []
|