paypal-csv-reports 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +2 -0
- data/lib/paypal/csv/reports/case_report.rb +43 -0
- data/lib/paypal/csv/reports/version.rb +7 -0
- data/lib/paypal/csv/reports.rb +2 -0
- data/paypal-csv-reports.gemspec +24 -0
- data/spec/fixtures/DDR-20150907.01.008.CSV +17 -0
- data/spec/spec_helper.rb +1 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ccfba231de0384f143c54d1c2e82ffc2282e05c6
|
4
|
+
data.tar.gz: 778faec4a474485514ff35d7189a325a8448e49c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8d15cd4979212f9ed502c3ad4c6e7ebb4202418a60cb0eff289626cf8831d1774a330f68c49caf76373b87ad3e3b84151cae71506cbe13bcb695e6db163b79f
|
7
|
+
data.tar.gz: aeb07639ad6cc1d61cf9b07cc6702c529cfa8260eceba5fac3cdb45878e637c275eddd94931d10b95bb65ddd5ea3ea0614a02e7355d406f4dabfe68c53a6c64e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Laurynas Butkus
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Simple PayPal CSV report parser
|
2
|
+
|
3
|
+
Parses PayPal case report CSV.
|
4
|
+
|
5
|
+
[CSV format](https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/PP_LRD_GenDisputeReport.pdf)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'paypal-csv-reports'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install paypal-csv-reports
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
csv_file = 'DDR-20150907.01.008.CSV'
|
27
|
+
report = ::Paypal::Csv::Reports::CaseReport.build(csv_file)
|
28
|
+
|
29
|
+
report.entries.each do |entry|
|
30
|
+
p entry
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Entry example:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
{:case_type=>"Claim",
|
38
|
+
:case_id=>"PP-004-117-699-911",
|
39
|
+
:original_transaction_id=>"00389221H1783294G",
|
40
|
+
:transaction_date=>"2015/08/13 07:50:09 +0200",
|
41
|
+
:transaction_invoice_id=>nil,
|
42
|
+
:card_type=>nil,
|
43
|
+
:case_reason=>"Not as described",
|
44
|
+
:claimant_name=>"testami",
|
45
|
+
:claimant_email_address=>"aaaa@hotmail.com",
|
46
|
+
:case_filing_date=>"2015/08/17 00:38:57 +0200",
|
47
|
+
:case_status=>"Being Reviewed By PayPal",
|
48
|
+
:response_due_date=>nil,
|
49
|
+
:disputed_amount=>"221",
|
50
|
+
:disputed_currency=>"USD",
|
51
|
+
:disputed_transaction_id=>nil,
|
52
|
+
:money_movement=>"No Impact",
|
53
|
+
:settlement_type=>nil,
|
54
|
+
:seller_protection=>"Ineligible",
|
55
|
+
:seller_protection_payout_amount=>nil,
|
56
|
+
:seller_protection_currency=>nil,
|
57
|
+
:payment_tracking_id=>"tracking-id-123",
|
58
|
+
:buyer_comments=>"When the rain comes tumbling down",
|
59
|
+
:store_id=>nil,
|
60
|
+
:chargeback_reason_code=>nil,
|
61
|
+
:outcome=>"None"}
|
62
|
+
```
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork it ( https://github.com/laurynas/paypal-csv-reports/fork )
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Paypal
|
4
|
+
module Csv
|
5
|
+
module Reports
|
6
|
+
class CaseReport
|
7
|
+
def self.build(file)
|
8
|
+
new(File.open(file, 'r:bom|utf-8'))
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :header
|
12
|
+
attr_reader :entries
|
13
|
+
|
14
|
+
def initialize(csv)
|
15
|
+
@entries = []
|
16
|
+
|
17
|
+
parse(csv)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def parse(csv)
|
23
|
+
::CSV.parse(csv) { |row| parse_row(row) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_row(row)
|
27
|
+
row_type = row.shift.to_s.strip
|
28
|
+
|
29
|
+
case row_type
|
30
|
+
when 'CH'
|
31
|
+
@header = parse_header(row)
|
32
|
+
when 'SB'
|
33
|
+
@entries << Hash[@header.zip(row)]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_header(row)
|
38
|
+
row.map { |v| v.downcase.gsub(' ', '_').to_sym }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'paypal/csv/reports/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'paypal-csv-reports'
|
8
|
+
spec.version = Paypal::Csv::Reports::VERSION
|
9
|
+
spec.authors = ['Laurynas Butkus']
|
10
|
+
spec.email = ['laurynas.butkus@gmail.com']
|
11
|
+
spec.summary = %q{Simple PayPal CSV report parser}
|
12
|
+
spec.description = %q{Parses PayPal case report CSV}
|
13
|
+
spec.homepage = 'https://github.com/laurynas/paypal-csv-reports'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '>= 3.0.0'
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"RH","2015/09/08 06:56:10 +0200",R,XAAAA4K4R24FQ,008,,,,,,,,,,,,,,,,,,,,,
|
2
|
+
"FH",01
|
3
|
+
SH,"2015/09/07 00:00:00 +0200","2015/09/07 23:59:59 +0200","XAAAA4K4R24FQ
|
4
|
+
",,,,,,,,,,,,,,,,,,,,,,
|
5
|
+
"CH","Case type","Case ID","Original transaction ID","Transaction date","Transaction invoice ID","Card Type","Case reason","Claimant name","Claimant email address","Case filing date","Case status","Response due date","Disputed amount","Disputed currency","Disputed transaction ID","Money movement","Settlement type","Seller protection","Seller protection payout amount","Seller protection currency","Payment Tracking ID","Buyer comments","Store ID","Chargeback Reason Code","Outcome"
|
6
|
+
SB,Claim,PP-004-117-699-911,00389221H1783294G,"2015/08/13 07:50:09 +0200",,,"Not as described",testami,aaaa@hotmail.com,"2015/08/17 00:38:57 +0200","Being Reviewed By PayPal",,"221",GBP,,"No Impact",,Ineligible,,,tracking-id-123,"When the rain comes tumbling down",,,None
|
7
|
+
SB,Dispute,PP-004-327-396-223,4JS20212KJ0029310,"2015/08/11 21:44:11 +0200",,,"Not as described",ZeiBa,bbbb@gmail.com,"2015/08/19 23:42:13 +0200",Open,,"322",GBP,1JE23435A5134245N,"Temp Hold Placed",Reversal,Ineligible,,,tracking-id-121,"In the country or the town",,,
|
8
|
+
SB,Dispute,PP-004-142-417-918,0YL28962211112212,"2015/08/19 15:14:17 +0200",,,Non-receipt,gogola,cccc@gmail.com,"2015/08/27 11:11:59 +0200",Open,,"533",EUR,1RE63259K48740416,"Temp Hold Placed",Reversal,Ineligible,,,tracking-id-444,"All good little girls and boys ",,,
|
9
|
+
SB,Dispute,PP-004-237-637-227,6K282472CJ696274C,"2015/08/06 17:43:36 +0200",,,Non-receipt,MerinMa,dddd@gmail.com,"2015/08/29 21:30:55 +0200",Open,,"4212",GBP,88G74315RN493714B,"Temp Hold Placed",Reversal,Ineligible,,,tracking-id-421,"Stay at home and mind their toys",,,
|
10
|
+
SB,Claim,PP-004-140-284-232,5XG54142311478349,"2015/08/26 18:47:37 +0200",,,"Not as described",NédEama,eeee@gmail.com,"2015/08/31 17:29:02 +0200","Being Reviewed By PayPal",,"433",EUR,,"Temp Hold Placed",,Ineligible,,,tracking-id-212,"Robert thought, - ""No, when it pours, It is better out of doors."" ",,,None
|
11
|
+
SB,Dispute,PP-004-112-656-217,299737213T2224914,"2015/08/29 01:09:02 +0200",,,Non-receipt,JaeyKa,fffff@gmail.uk,"2015/09/01 17:57:18 +0200",Open,,"234",GBP,73U88619WR432143T,"Temp Hold Placed",Reversal,Ineligible,,,"tracking-id-322","Rain it did, and in a minute",,,
|
12
|
+
SB,Dispute,PP-004-129-679-232,8P1494333Y395013V,"2015/08/12 16:55:05 +0200",,,Non-receipt,ajaaja,qwww@gmail.com,"2015/09/04 15:01:04 +0200",Open,,"432",GBP,13398111SU1809921,"Temp Hold Placed",Reversal,Ineligible,,,"tracking-id-322","Bob was in it",,,
|
13
|
+
"SF",7
|
14
|
+
"SC",7
|
15
|
+
"RF",7
|
16
|
+
"RC",7
|
17
|
+
"FF",7
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'paypal/csv/reports'
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paypal-csv-reports
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Laurynas Butkus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
description: Parses PayPal case report CSV
|
56
|
+
email:
|
57
|
+
- laurynas.butkus@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/paypal/csv/reports.rb
|
69
|
+
- lib/paypal/csv/reports/case_report.rb
|
70
|
+
- lib/paypal/csv/reports/version.rb
|
71
|
+
- paypal-csv-reports.gemspec
|
72
|
+
- spec/fixtures/DDR-20150907.01.008.CSV
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: https://github.com/laurynas/paypal-csv-reports
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.5
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Simple PayPal CSV report parser
|
98
|
+
test_files:
|
99
|
+
- spec/fixtures/DDR-20150907.01.008.CSV
|
100
|
+
- spec/spec_helper.rb
|