tindie2easypost 0.1.6 → 0.2.0
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 +4 -4
- data/README.md +16 -0
- data/bin/tindie2easypost.rb +31 -54
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ca9c57f213094649a1d0f76bd2f649bed0660d797a45fb63de222121a401f9c
|
4
|
+
data.tar.gz: 683c477928ab40fb9770c564484313558ee0f4a5ca26838a45f55e30077a94a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82a4beab1f68a940b4c4c22dee30aa915d6aee7a49bab93485324d211422dec579b2d79b506305ed9f98f05ec27d759cd69804378cd3087206529b8e33140742
|
7
|
+
data.tar.gz: c97829b7859af671d0921aa17c554b658117d4bcd27cebb95d78c6ebe74149ceb20fe6589348235e259ce7bf841f9331b8f41c8f70cf5b4717ba7b9f84fcb34d
|
data/README.md
CHANGED
@@ -37,6 +37,7 @@ This Ruby script converts CSV files exported from Tindie into a format compatibl
|
|
37
37
|
ruby tindie2easypost.rb -i input_tindie_orders.csv -o output_easypost_orders.csv -f 'Your Name,Your Company,Your Phone,Your Email,Your Street,Unit/Suite,Your City,Your State,Your Zip,Your Country'
|
38
38
|
```
|
39
39
|
|
40
|
+
|
40
41
|
### Command-Line Arguments
|
41
42
|
|
42
43
|
- `-i` or `--input`: Path to the input Tindie CSV file (required)
|
@@ -52,6 +53,10 @@ ruby tindie2easypost.rb -i input_tindie_orders.csv -o output_easypost_orders.csv
|
|
52
53
|
8. State
|
53
54
|
9. Zip/Postal Code
|
54
55
|
10. Country
|
56
|
+
- `-p` or `--package`: Package dimensions and weight, comma-separated (LENGTH,WIDTH,HEIGHT,WEIGHT)
|
57
|
+
- `-d` or `--predefined`: Predefined package type
|
58
|
+
|
59
|
+
Note: You must use either `-p` or `-d`, but not both.
|
55
60
|
|
56
61
|
### Example
|
57
62
|
|
@@ -59,11 +64,22 @@ ruby tindie2easypost.rb -i input_tindie_orders.csv -o output_easypost_orders.csv
|
|
59
64
|
ruby tindie2easypost.rb -i december_orders.csv -o easypost_shipping.csv -f 'John Doe,Acme Widgets,555-123-4567,john@example.com,123 Business St,Suite 100,Anytown,CA,90210,USA'
|
60
65
|
```
|
61
66
|
|
67
|
+
With package dimensions
|
68
|
+
```bash
|
69
|
+
ruby tindie2easypost.rb -i december_orders.csv -o easypost_shipping.csv -f 'John Doe,Acme Widgets,555-123-4567,john@example.com,123 Business St,Suite 100,Anytown,CA,90210,USA' -p 10,8,6,16
|
70
|
+
```
|
71
|
+
|
72
|
+
With predefined package type
|
73
|
+
```bash
|
74
|
+
ruby tindie2easypost.rb -i december_orders.csv -o easypost_shipping.csv -f 'John Doe,Acme Widgets,555-123-4567,john@example.com,123 Business St,Suite 100,Anytown,CA,90210,USA' -d "SmallFlatRateBox"
|
75
|
+
```
|
76
|
+
|
62
77
|
## Limitations
|
63
78
|
|
64
79
|
- Parcel details (weight, dimensions) are not automatically populated
|
65
80
|
- Carrier information is not automatically filled
|
66
81
|
- Assumes a consistent sender address for all orders
|
82
|
+
- Assumes user wants `USPS GroundAdvantage` Service
|
67
83
|
|
68
84
|
## Customization
|
69
85
|
|
data/bin/tindie2easypost.rb
CHANGED
@@ -4,17 +4,16 @@ require 'csv'
|
|
4
4
|
require 'optparse'
|
5
5
|
|
6
6
|
class Tindie2EasyPost
|
7
|
-
def initialize(input_file, output_file, from_address)
|
7
|
+
def initialize(input_file, output_file, from_address, package_params)
|
8
8
|
@input_file = input_file
|
9
9
|
@output_file = output_file
|
10
10
|
@from_address = from_address
|
11
|
+
@package_params = package_params
|
11
12
|
end
|
12
13
|
|
13
14
|
def convert
|
14
|
-
# Read Tindie CSV
|
15
15
|
tindie_data = CSV.read(@input_file, headers: true)
|
16
16
|
|
17
|
-
# Prepare EasyPost CSV headers
|
18
17
|
easypost_headers = [
|
19
18
|
'to_address.name', 'to_address.company', 'to_address.phone', 'to_address.email',
|
20
19
|
'to_address.street1', 'to_address.street2', 'to_address.city', 'to_address.state',
|
@@ -26,50 +25,23 @@ class Tindie2EasyPost
|
|
26
25
|
'parcel.predefined_package', 'carrier', 'service'
|
27
26
|
]
|
28
27
|
|
29
|
-
# Write EasyPost CSV
|
30
28
|
CSV.open(@output_file, 'w') do |csv|
|
31
29
|
csv << easypost_headers
|
32
30
|
|
33
|
-
# Predefined from address values
|
34
31
|
from_address_values = [
|
35
|
-
@from_address[:name],
|
36
|
-
@from_address[:
|
37
|
-
@from_address[:
|
38
|
-
@from_address[:email], # from_address.email
|
39
|
-
@from_address[:street1], # from_address.street1
|
40
|
-
@from_address[:street2] || '', # from_address.street2
|
41
|
-
@from_address[:city], # from_address.city
|
42
|
-
@from_address[:state], # from_address.state
|
43
|
-
@from_address[:zip], # from_address.zip
|
44
|
-
@from_address[:country], # from_address.country
|
32
|
+
@from_address[:name], @from_address[:company], @from_address[:phone], @from_address[:email],
|
33
|
+
@from_address[:street1], @from_address[:street2] || '', @from_address[:city], @from_address[:state],
|
34
|
+
@from_address[:zip], @from_address[:country],
|
45
35
|
]
|
46
36
|
|
47
37
|
tindie_data.each do |row|
|
48
|
-
# Map Tindie data to EasyPost format
|
49
38
|
easypost_row = [
|
50
|
-
#
|
51
|
-
|
52
|
-
row['Company'], # to_address.company
|
53
|
-
row['Phone'], # to_address.phone
|
54
|
-
row['Email'], # to_address.email
|
55
|
-
row['Street'], # to_address.street1
|
56
|
-
'', # to_address.street2 (empty if not in Tindie)
|
57
|
-
row['City'], # to_address.city
|
58
|
-
row['State/Province'], # to_address.state
|
59
|
-
row['Postal/Zip Code'], # to_address.zip
|
60
|
-
row['Country'], # to_address.country
|
61
|
-
|
62
|
-
# From Address (using predefined values)
|
39
|
+
"#{row['First Name']} #{row['Last Name']}", row['Company'], row['Phone'], row['Email'],
|
40
|
+
row['Street'], '', row['City'], row['State/Province'], row['Postal/Zip Code'], row['Country'],
|
63
41
|
*from_address_values,
|
64
|
-
|
65
|
-
|
66
|
-
'',
|
67
|
-
'', # parcel.width
|
68
|
-
'', # parcel.height
|
69
|
-
'', # parcel.weight
|
70
|
-
'', # parcel.predefined_package
|
71
|
-
'', # carrier
|
72
|
-
row['Shipping Method'] # service
|
42
|
+
@package_params[:length], @package_params[:width], @package_params[:height], @package_params[:weight],
|
43
|
+
@package_params[:predefined_package],
|
44
|
+
'USPS', 'GroundAdvantage'
|
73
45
|
]
|
74
46
|
|
75
47
|
csv << easypost_row
|
@@ -80,7 +52,6 @@ class Tindie2EasyPost
|
|
80
52
|
end
|
81
53
|
end
|
82
54
|
|
83
|
-
# Command-line argument parsing
|
84
55
|
options = {}
|
85
56
|
OptionParser.new do |opts|
|
86
57
|
opts.banner = "Usage: tindie2easypost.rb [options]"
|
@@ -95,31 +66,37 @@ OptionParser.new do |opts|
|
|
95
66
|
|
96
67
|
opts.on("-f", "--from NAME,COMPANY,PHONE,EMAIL,STREET1,STREET2,CITY,STATE,ZIP,COUNTRY", Array, "From Address Details") do |from_details|
|
97
68
|
options[:from_address] = {
|
98
|
-
name: from_details[0],
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
69
|
+
name: from_details[0], company: from_details[1], phone: from_details[2], email: from_details[3],
|
70
|
+
street1: from_details[4], street2: from_details[5], city: from_details[6], state: from_details[7],
|
71
|
+
zip: from_details[8], country: from_details[9]
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
opts.on("-p", "--package LENGTH,WIDTH,HEIGHT,WEIGHT", Array, "Package dimensions and weight") do |package|
|
76
|
+
options[:package_params] = {
|
77
|
+
length: package[0], width: package[1], height: package[2], weight: package[3],
|
78
|
+
predefined_package: ''
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
opts.on("-d", "--predefined PACKAGE", "Predefined package type") do |predefined|
|
83
|
+
options[:package_params] = {
|
84
|
+
length: '', width: '', height: '', weight: '',
|
85
|
+
predefined_package: predefined
|
108
86
|
}
|
109
87
|
end
|
110
88
|
end.parse!
|
111
89
|
|
112
|
-
|
113
|
-
unless options[:input] && options[:output] && options[:from_address]
|
90
|
+
unless options[:input] && options[:output] && options[:from_address] && (options[:package_params])
|
114
91
|
puts "Error: Missing required arguments"
|
115
|
-
puts "Usage: ruby tindie2easypost.rb -i input.csv -o output.csv -f '
|
92
|
+
puts "Usage: ruby tindie2easypost.rb -i input.csv -o output.csv -f 'Name,Company,Phone,Email,Street1,Street2,City,State,Zip,Country' (-p LENGTH,WIDTH,HEIGHT,WEIGHT | -d PREDEFINED_PACKAGE)"
|
116
93
|
exit 1
|
117
94
|
end
|
118
95
|
|
119
|
-
# Run conversion
|
120
96
|
converter = Tindie2EasyPost.new(
|
121
97
|
options[:input],
|
122
98
|
options[:output],
|
123
|
-
options[:from_address]
|
99
|
+
options[:from_address],
|
100
|
+
options[:package_params]
|
124
101
|
)
|
125
102
|
converter.convert
|