embulk-input-sendgrid 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -9
- data/embulk-input-sendgrid.gemspec +3 -3
- data/lib/embulk/input/sendgrid.rb +7 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a3021b808886f9a8e8396cea78f63b81fa53a710b8f3e5ee694c1009e948b1
|
4
|
+
data.tar.gz: 2a988676b09ff6ad7b8d72cd751c2a822884d3b737555c398db4bec44e5fdbc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bb1511ccb13c79d62f3be1ee11709495e17a34e2d80f8eb583b084b25c02f01479061626ed97ab7ba42021dd1056eda47dd7283581105a96ea0f7e6da82cb3
|
7
|
+
data.tar.gz: 9c465ad8be62329387be25f798cd558c711606ce35b45d029e487fe4715399f81ec69eb8bb131c9f99f146d1fbf1d981780dfb35845088d02e46430c6c101885
|
data/README.md
CHANGED
@@ -1,32 +1,33 @@
|
|
1
1
|
# Sendgrid input plugin for Embulk
|
2
2
|
|
3
|
-
|
3
|
+
Embulk input plugin for SendGrid stats
|
4
4
|
|
5
5
|
## Overview
|
6
6
|
|
7
7
|
* **Plugin type**: input
|
8
|
-
* **Resume supported**:
|
9
|
-
* **Cleanup supported**:
|
8
|
+
* **Resume supported**: no
|
9
|
+
* **Cleanup supported**: no
|
10
10
|
* **Guess supported**: no
|
11
11
|
|
12
12
|
## Configuration
|
13
13
|
|
14
|
-
- **
|
15
|
-
- **
|
16
|
-
- **
|
14
|
+
- **api_key**: SendGrid API Key that requires Stats read permission (string, required)
|
15
|
+
- **start_date**: Start date for loading data, e.g. 2020-01-01(string, required)
|
16
|
+
- **end_date**: End date for loading data, e.g. 2020-02-01 (string, default: `today`)
|
17
17
|
|
18
18
|
## Example
|
19
19
|
|
20
20
|
```yaml
|
21
21
|
in:
|
22
22
|
type: sendgrid
|
23
|
-
|
24
|
-
|
23
|
+
api_key: YourAPIKey
|
24
|
+
start_date: 2020-01-01
|
25
|
+
end_date: 2020-02-01
|
25
26
|
```
|
26
27
|
|
27
28
|
|
28
29
|
## Build
|
29
30
|
|
30
31
|
```
|
31
|
-
$ rake
|
32
|
+
$ rake build
|
32
33
|
```
|
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-input-sendgrid"
|
4
|
-
spec.version = "0.1.
|
5
|
-
spec.authors = [""]
|
4
|
+
spec.version = "0.1.2"
|
5
|
+
spec.authors = ["kaacun"]
|
6
6
|
spec.summary = "Sendgrid input plugin for Embulk"
|
7
7
|
spec.description = "Loads records from Sendgrid."
|
8
8
|
spec.email = [""]
|
9
9
|
spec.licenses = ["MIT"]
|
10
|
-
|
10
|
+
spec.homepage = "https://github.com/kaacun/embulk-input-sendgrid"
|
11
11
|
|
12
12
|
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
13
13
|
spec.test_files = spec.files.grep(%r{^(test|spec)/})
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Embulk
|
2
2
|
module Input
|
3
|
-
|
4
3
|
require 'json'
|
5
4
|
require 'rest-client'
|
6
5
|
|
@@ -11,7 +10,7 @@ module Embulk
|
|
11
10
|
task = {
|
12
11
|
api_key: config.param(:api_key, :string),
|
13
12
|
start_date: config.param(:start_date, :string),
|
14
|
-
end_date: config.param(:end_date, :string, default: '')
|
13
|
+
end_date: config.param(:end_date, :string, default: 'today')
|
15
14
|
}
|
16
15
|
|
17
16
|
columns = [
|
@@ -32,7 +31,7 @@ module Embulk
|
|
32
31
|
Column.new(14, 'unique_clicks', :long),
|
33
32
|
Column.new(15, 'unique_opens', :long),
|
34
33
|
Column.new(16, 'unsubscribe_drops', :long),
|
35
|
-
Column.new(17, 'unsubscribes', :long)
|
34
|
+
Column.new(17, 'unsubscribes', :long)
|
36
35
|
]
|
37
36
|
|
38
37
|
resume(task, columns, 1, &control)
|
@@ -48,11 +47,12 @@ module Embulk
|
|
48
47
|
def run
|
49
48
|
max_category_limit = 100
|
50
49
|
|
51
|
-
date = Date.parse(@task[:start_date])
|
52
|
-
end_date = @task[:end_date]
|
50
|
+
date = @task[:start_date] == 'today' ? Date.today : Date.parse(@task[:start_date])
|
51
|
+
end_date = @task[:end_date] == 'today' ? Date.today : Date.parse(@task[:end_date])
|
52
|
+
endpoint = 'https://api.sendgrid.com/v3/categories/stats/sums'
|
53
53
|
|
54
|
-
while date <= end_date
|
55
|
-
json = RestClient.get(
|
54
|
+
while date <= end_date
|
55
|
+
json = RestClient.get(endpoint, { params: { start_date: date.strftime("%Y-%m-%d"), limit: max_category_limit }, Authorization: "Bearer #{@task[:api_key]}", content_type: 'application/json' })
|
56
56
|
results = JSON.parse(json)
|
57
57
|
|
58
58
|
results["stats"].each do |metrics|
|
@@ -66,6 +66,5 @@ module Embulk
|
|
66
66
|
{}
|
67
67
|
end
|
68
68
|
end
|
69
|
-
|
70
69
|
end
|
71
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-sendgrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- kaacun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -85,7 +85,7 @@ files:
|
|
85
85
|
- example/Gemfile.lock
|
86
86
|
- example/example.yml
|
87
87
|
- lib/embulk/input/sendgrid.rb
|
88
|
-
homepage:
|
88
|
+
homepage: https://github.com/kaacun/embulk-input-sendgrid
|
89
89
|
licenses:
|
90
90
|
- MIT
|
91
91
|
metadata: {}
|