compensated 0.1.0.pre4 → 0.1.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/compensated/gumroad/event_parser.rb +28 -15
- data/lib/compensated/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd4ea31bad4284f0d06de15e35b591e22d67b7cc50a1571ef7625d5ef21861b2
|
4
|
+
data.tar.gz: 17fc45a9d3a5f69148b4ace3f93ad9617bdafb5b77be9ac19465f102b071eee0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72e5586b802db61e8ba14af7f26e04381bbc1ab40fcc597ec496efc5420173f37e2a34af549732a4b081a451fe3f3527d0d5488fcf918c9f3d91198f69bc3b9
|
7
|
+
data.tar.gz: 31cfcdb556cbb130c131b6981231f650a4214d5bbceb7bed3f9dc0160a7838c6dc8257b512d07bcf1f0c8c9541919ae0b8eb75bbc7f28e177a7a8c00f3332f73
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "webrick"
|
1
2
|
module Compensated
|
2
3
|
module Gumroad
|
3
4
|
class EventParser
|
@@ -8,29 +9,41 @@ module Compensated
|
|
8
9
|
keys.include?(:seller_id) && keys.include?(:product_id) && keys.include?(:product_permalink) && request.data["product_permalink"].include?("gum.co")
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
request.body.rewind
|
15
|
-
else
|
16
|
-
body = request.body
|
17
|
-
end
|
18
|
-
|
12
|
+
def normalize(data_or_body)
|
13
|
+
data = data_or_body.respond_to?(:key) ? data_or_body : data_from_string(data_or_body)
|
14
|
+
body = data_or_body.respond_to?(:key) ? nil : data_or_body
|
19
15
|
{
|
20
16
|
raw_body: body,
|
21
|
-
raw_event_type:
|
17
|
+
raw_event_type: data["resource_name"].to_sym,
|
22
18
|
raw_event_id: nil,
|
23
19
|
payment_processor: :gumroad,
|
24
20
|
amount: {
|
25
|
-
paid:
|
26
|
-
currency:
|
21
|
+
paid: data["price"].to_i,
|
22
|
+
currency: data["currency"].upcase,
|
27
23
|
},
|
28
24
|
customer: {
|
29
|
-
id:
|
30
|
-
email:
|
31
|
-
name:
|
25
|
+
id: data["purchaser_id"].to_s,
|
26
|
+
email: data["email"],
|
27
|
+
name: data["full_name"],
|
32
28
|
},
|
33
|
-
}
|
29
|
+
}.compact
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse(request)
|
33
|
+
normalize(request.body)
|
34
|
+
end
|
35
|
+
|
36
|
+
private def read_and_rewind(body)
|
37
|
+
if body.respond_to?(:read)
|
38
|
+
body = body.read
|
39
|
+
body.rewind
|
40
|
+
else
|
41
|
+
body
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private def data_from_string(body)
|
46
|
+
WEBrick::HTTPUtils.parse_query(read_and_rewind(body))
|
34
47
|
end
|
35
48
|
end
|
36
49
|
Compensated.event_parsers.push(Gumroad::EventParser.new)
|
data/lib/compensated/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compensated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|