embulk-input-sendgrid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +45 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +3 -0
- data/embulk-input-sendgrid.gemspec +21 -0
- data/example/Gemfile +7 -0
- data/example/Gemfile.lock +44 -0
- data/example/example.yml +10 -0
- data/lib/embulk/input/sendgrid.rb +70 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8d7763865c3a41830787185e8e6bc6b8c87d00f675b9e9dade87329486373026
|
4
|
+
data.tar.gz: ded86d252917c75e8baba0dc8ac38e51ebc61ae408b9612d4847c7299d345b41
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 155ef2da85e19d1b50c52eea22c27404fac8804a44b6ce159db688122ddb26704e9d38b34de95894822196fcfa77b63c216bf4767a0daa84434ca82f6e5e076a
|
7
|
+
data.tar.gz: e4513dc8c3f21e204bf69320fdf6599c805dc3766d8cac0d608461368a8fe7d51065e8da07527e6e2b6f09e3cd39a1a2a97f96272ff8bc74d56b68a01aab5833
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
embulk-input-sendgrid (0.1.0)
|
5
|
+
rest-client (>= 1.8.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
domain_name (0.5.20190701)
|
11
|
+
unf (>= 0.0.5, < 1.0.0)
|
12
|
+
embulk (0.8.39-java)
|
13
|
+
bundler (>= 1.10.6)
|
14
|
+
liquid (~> 4.0.0)
|
15
|
+
msgpack (~> 1.1.0)
|
16
|
+
rjack-icu (~> 4.54.1.1)
|
17
|
+
http-accept (1.7.0)
|
18
|
+
http-cookie (1.0.3)
|
19
|
+
domain_name (~> 0.5)
|
20
|
+
liquid (4.0.3)
|
21
|
+
mime-types (3.3.1)
|
22
|
+
mime-types-data (~> 3.2015)
|
23
|
+
mime-types-data (3.2019.1009)
|
24
|
+
msgpack (1.1.0-java)
|
25
|
+
netrc (0.11.0)
|
26
|
+
rake (13.0.1)
|
27
|
+
rest-client (2.1.0)
|
28
|
+
http-accept (>= 1.7.0, < 2.0)
|
29
|
+
http-cookie (>= 1.0.2, < 2.0)
|
30
|
+
mime-types (>= 1.16, < 4.0)
|
31
|
+
netrc (~> 0.8)
|
32
|
+
rjack-icu (4.54.1.1-java)
|
33
|
+
unf (0.1.4-java)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
java
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (>= 1.10.6)
|
40
|
+
embulk (>= 0.8.39)
|
41
|
+
embulk-input-sendgrid!
|
42
|
+
rake (>= 10.0)
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.10.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Kazuto Ohara
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Sendgrid input plugin for Embulk
|
2
|
+
|
3
|
+
TODO: Write short description here and embulk-input-sendgrid.gemspec file.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: input
|
8
|
+
* **Resume supported**: yes
|
9
|
+
* **Cleanup supported**: yes
|
10
|
+
* **Guess supported**: no
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
- **option1**: description (integer, required)
|
15
|
+
- **option2**: description (string, default: `"myvalue"`)
|
16
|
+
- **option3**: description (string, default: `null`)
|
17
|
+
|
18
|
+
## Example
|
19
|
+
|
20
|
+
```yaml
|
21
|
+
in:
|
22
|
+
type: sendgrid
|
23
|
+
option1: example1
|
24
|
+
option2: example2
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Build
|
29
|
+
|
30
|
+
```
|
31
|
+
$ rake
|
32
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "embulk-input-sendgrid"
|
4
|
+
spec.version = "0.1.0"
|
5
|
+
spec.authors = [""]
|
6
|
+
spec.summary = "Sendgrid input plugin for Embulk"
|
7
|
+
spec.description = "Loads records from Sendgrid."
|
8
|
+
spec.email = [""]
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
# TODO set this: spec.homepage = "https://github.com//embulk-input-sendgrid"
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
|
17
|
+
spec.add_dependency 'rest-client', ['>= 1.8.0']
|
18
|
+
spec.add_development_dependency 'embulk', ['>= 0.8.39']
|
19
|
+
spec.add_development_dependency 'bundler', ['>= 1.10.6']
|
20
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
21
|
+
end
|
data/example/Gemfile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
embulk-input-sendgrid (0.1.0)
|
5
|
+
rest-client (>= 1.8.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
domain_name (0.5.20190701)
|
11
|
+
unf (>= 0.0.5, < 1.0.0)
|
12
|
+
embulk (0.8.39-java)
|
13
|
+
bundler (>= 1.10.6)
|
14
|
+
liquid (~> 4.0.0)
|
15
|
+
msgpack (~> 1.1.0)
|
16
|
+
rjack-icu (~> 4.54.1.1)
|
17
|
+
embulk-formatter-fast_jsonl (0.1.2)
|
18
|
+
embulk-output-command (0.1.4)
|
19
|
+
http-cookie (1.0.3)
|
20
|
+
domain_name (~> 0.5)
|
21
|
+
liquid (4.0.3)
|
22
|
+
mime-types (3.2.2)
|
23
|
+
mime-types-data (~> 3.2015)
|
24
|
+
mime-types-data (3.2019.0331)
|
25
|
+
msgpack (1.1.0-java)
|
26
|
+
netrc (0.11.0)
|
27
|
+
rest-client (2.0.2)
|
28
|
+
http-cookie (>= 1.0.2, < 2.0)
|
29
|
+
mime-types (>= 1.16, < 4.0)
|
30
|
+
netrc (~> 0.8)
|
31
|
+
rjack-icu (4.54.1.1-java)
|
32
|
+
unf (0.1.4-java)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
java
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
embulk
|
39
|
+
embulk-formatter-fast_jsonl
|
40
|
+
embulk-input-sendgrid!
|
41
|
+
embulk-output-command
|
42
|
+
|
43
|
+
BUNDLED WITH
|
44
|
+
1.10.6
|
data/example/example.yml
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
module Embulk
|
2
|
+
module Input
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'rest-client'
|
6
|
+
|
7
|
+
class Sendgrid < InputPlugin
|
8
|
+
Plugin.register_input("sendgrid", self)
|
9
|
+
|
10
|
+
def self.transaction(config, &control)
|
11
|
+
task = {
|
12
|
+
api_key: config.param(:api_key, :string),
|
13
|
+
start_date: config.param(:start_date, :string),
|
14
|
+
end_date: config.param(:end_date, :string, default: '')
|
15
|
+
}
|
16
|
+
|
17
|
+
columns = [
|
18
|
+
Column.new(0, 'date', :timestamp),
|
19
|
+
Column.new(1, 'category', :string),
|
20
|
+
Column.new(2, 'blocks', :long),
|
21
|
+
Column.new(3, 'bounce_drops', :long),
|
22
|
+
Column.new(4, 'bounces', :long),
|
23
|
+
Column.new(5, 'clicks', :long),
|
24
|
+
Column.new(6, 'deferred', :long),
|
25
|
+
Column.new(7, 'delivered', :long),
|
26
|
+
Column.new(8, 'invalid_emails', :long),
|
27
|
+
Column.new(9, 'opens', :long),
|
28
|
+
Column.new(10, 'processed', :long),
|
29
|
+
Column.new(11, 'requests', :long),
|
30
|
+
Column.new(12, 'spam_report_drops', :long),
|
31
|
+
Column.new(13, 'spam_reports', :long),
|
32
|
+
Column.new(14, 'unique_clicks', :long),
|
33
|
+
Column.new(15, 'unique_opens', :long),
|
34
|
+
Column.new(16, 'unsubscribe_drops', :long),
|
35
|
+
Column.new(17, 'unsubscribes', :long),
|
36
|
+
]
|
37
|
+
|
38
|
+
resume(task, columns, 1, &control)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.resume(task, columns, count, &control)
|
42
|
+
task_reports = yield(task, columns, count)
|
43
|
+
|
44
|
+
next_config_diff = {}
|
45
|
+
return next_config_diff
|
46
|
+
end
|
47
|
+
|
48
|
+
def run
|
49
|
+
max_category_limit = 100
|
50
|
+
|
51
|
+
date = Date.parse(@task[:start_date])
|
52
|
+
end_date = @task[:end_date] != "" ? Date.parse(@task[:end_date]) : Date.today
|
53
|
+
|
54
|
+
while date <= end_date do
|
55
|
+
json = RestClient.get("https://api.sendgrid.com/v3/categories/stats/sums?start_date=#{date.strftime("%Y-%m-%d")}&limit=#{max_category_limit}", {:Authorization => "Bearer #{@task[:api_key]}", :content_type => 'application/json'})
|
56
|
+
results = JSON.parse(json)
|
57
|
+
|
58
|
+
results["stats"].each do |metrics|
|
59
|
+
@page_builder.add(metrics["metrics"].values.unshift(metrics["name"]).unshift(Time.parse(results["date"])))
|
60
|
+
end
|
61
|
+
|
62
|
+
date = date.next_day
|
63
|
+
end
|
64
|
+
|
65
|
+
@page_builder.finish
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-input-sendgrid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ''
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: embulk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.39
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.8.39
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.10.6
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.10.6
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Loads records from Sendgrid.
|
70
|
+
email:
|
71
|
+
- ''
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- LICENSE
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- embulk-input-sendgrid.gemspec
|
84
|
+
- example/Gemfile
|
85
|
+
- example/Gemfile.lock
|
86
|
+
- example/example.yml
|
87
|
+
- lib/embulk/input/sendgrid.rb
|
88
|
+
homepage:
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.0.3
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Sendgrid input plugin for Embulk
|
111
|
+
test_files: []
|