catprint 0.0.1

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.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ About:
2
+ ======
3
+ This is a simple wrapper around CatPrint's ActionPrint API, allowing developers to interact with the service in pure Ruby.
4
+
5
+ Documentation and More Information:
6
+ ===================================
7
+ https://docs.google.com/View?id=dd5gnbcf_80cf4x2qf8
8
+ http://www.catprint.com/action_print
9
+
10
+ (Hopefully) Sensible Defaults:
11
+ ==============================
12
+ Most of the time attributes default to nil, but the following defaults were chosen:
13
+ production_center_id = 1
14
+ payment_method = "pay_on_account"
15
+ shipping_speed = 7
16
+ job_copies = 1
17
+ job_full_bleed = true
18
+ job_paper_id = "HCS1SG"
19
+ job_finishing_option_id = "1F"
20
+ job_fold_across_long_edge = true
21
+ job_front_imaging = "color"
22
+ job_back_imaging = "blank"
23
+ job_flip_on_long_edge = true
24
+ job_pages = 1
25
+ panel_number = 1
26
+ page_number = 1
27
+ rotation = 0
28
+
29
+ Installation:
30
+ =============
31
+ (sudo) gem install catprint
32
+
33
+ Here is an example Sinatra application to get you going:
34
+ --------------------------------------------------------
35
+
36
+ require 'rubygems'
37
+ require 'sinatra'
38
+ require 'catprint'
39
+
40
+ get '/' do
41
+ @catprint = CatPrint.new
42
+ @catprint.email = "YOUR_ACCOUNT_EMAIL"
43
+ @catprint.password = "YOUR_ACCOUNT_PASSWORD"
44
+ @catprint.payment_method = "credit_card"
45
+ @catprint.payment_amount = "12.35"
46
+ @catprint.card_expiration = "2011-11-01"
47
+ @catprint.card_number = "4111111111111111"
48
+ @catprint.card_type = "Visa"
49
+ @catprint.billing_name = "Name"
50
+ @catprint.billing_address_1 = "101 High Street"
51
+ @catprint.billing_city = "Rochester"
52
+ @catprint.billing_state = "NY"
53
+ @catprint.billing_zip = "14617"
54
+ @catprint.billing_country = "US"
55
+ @catprint.billing_phone = "585-278-6308"
56
+ @catprint.shipping_name = "Customers Name"
57
+ @catprint.shipping_address_1 = "92 Station Rd"
58
+ @catprint.shipping_city = "Rochester"
59
+ @catprint.shipping_state = "NY"
60
+ @catprint.shipping_zip = "14617"
61
+ @catprint.job_name = "5 X 7 Greeting Card Job (10 X 7 single fold)"
62
+ @catprint.job_width = "720.00"
63
+ @catprint.job_height = "504.00"
64
+ @catprint.panel_source_file = "http://www.catprint.com/action_print_samples/sample_pdf_greeting_card.pdf"
65
+ response = @catprint.send_job(@catprint.action_print_job_xml)
66
+ response.body.to_s
67
+ end
data/catprint.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+
3
+ SPEC = Gem::Specification.new do |s|
4
+ s.name = "catprint"
5
+ s.version = "0.0.1"
6
+ s.author = "Bryan Woods"
7
+ s.email = "bryanwoods4e@gmail.com"
8
+ s.platform = Gem::Platform::RUBY
9
+ s.description = "Ruby wrapper for the CatPrint API"
10
+ s.summary = "Allows Ruby developers to interact with CatPrint's ActionPrint API (http://www.catprint.com/action_print) with pure Ruby."
11
+ s.rubyforge_project = "catprint"
12
+ s.homepage = "http://github.com/bryanwoods/catprint"
13
+ s.files = Dir.glob("**/*")
14
+ s.require_path = "lib"
15
+ s.has_rdoc = false
16
+ s.add_dependency(%q<httparty>, [">= 0.6.1"])
17
+ end
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'sinatra'
3
+ require 'catprint'
4
+
5
+ get '/' do
6
+ @catprint = CatPrint.new
7
+ @catprint.email = "YOUR_ACCOUNT_EMAIL"
8
+ @catprint.password = "YOUR_ACCOUNT_PASSWORD"
9
+ @catprint.payment_method = "credit_card"
10
+ @catprint.payment_amount = "12.35"
11
+ @catprint.card_expiration = "2011-11-01"
12
+ @catprint.card_number = "4111111111111111"
13
+ @catprint.card_type = "Visa"
14
+ @catprint.billing_name = "Name"
15
+ @catprint.billing_address_1 = "101 High Street"
16
+ @catprint.billing_city = "Rochester"
17
+ @catprint.billing_state = "NY"
18
+ @catprint.billing_zip = "14617"
19
+ @catprint.billing_country = "US"
20
+ @catprint.billing_phone = "585-278-6308"
21
+ @catprint.shipping_name = "Customers Name"
22
+ @catprint.shipping_address_1 = "92 Station Rd"
23
+ @catprint.shipping_city = "Rochester"
24
+ @catprint.shipping_state = "NY"
25
+ @catprint.shipping_zip = "14617"
26
+ @catprint.job_name = "5 X 7 Greeting Card Job (10 X 7 single fold)"
27
+ @catprint.job_width = "720.00"
28
+ @catprint.job_height = "504.00"
29
+ @catprint.panel_source_file = "http://www.catprint.com/action_print_samples/sample_pdf_greeting_card.pdf"
30
+ response = @catprint.send_job(@catprint.action_print_job_xml)
31
+ response.body.to_s
32
+ end
data/lib/catprint.rb ADDED
@@ -0,0 +1,221 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+ class CatPrint
5
+ include HTTParty
6
+ attr_accessor :email,
7
+ :password,
8
+ :production_center_id,
9
+ :payment_method,
10
+ :payment_amount,
11
+ :card_expiration,
12
+ :card_number,
13
+ :card_type,
14
+ :card_holder_first_name,
15
+ :card_holder_last_name,
16
+ :billing_company,
17
+ :billing_name,
18
+ :billing_address_1,
19
+ :billing_address_2,
20
+ :billing_city,
21
+ :billing_state,
22
+ :billing_zip,
23
+ :billing_country,
24
+ :billing_phone,
25
+ :shipping_company,
26
+ :shipping_name,
27
+ :shipping_address_1,
28
+ :shipping_address_2,
29
+ :shipping_city,
30
+ :shipping_state,
31
+ :shipping_zip,
32
+ :shipping_country,
33
+ :shipping_phone,
34
+ :shipping_speed,
35
+ :shipping_instructions,
36
+ :drop_ship_company,
37
+ :drop_ship_address_1,
38
+ :drop_ship_address_2,
39
+ :drop_ship_city,
40
+ :drop_ship_state,
41
+ :drop_ship_zip,
42
+ :drop_ship_country,
43
+ :drop_ship_phone,
44
+ :drop_ship_packing_slip_url,
45
+ :job_name,
46
+ :job_copies,
47
+ :job_width,
48
+ :job_height,
49
+ :job_full_bleed,
50
+ :job_paper_id,
51
+ :job_envelope_id,
52
+ :job_finishing_option_id,
53
+ :job_fold_across_long_edge,
54
+ :job_front_imaging,
55
+ :job_back_imaging,
56
+ :job_flip_on_long_edge,
57
+ :job_pages,
58
+ :panel_source_file,
59
+ :panel_number,
60
+ :page_number,
61
+ :rotation
62
+
63
+ def initialize
64
+ @action_print_job_xml = action_print_job_xml
65
+ @production_center_id = production_center_id
66
+ @payment_method = payment_method
67
+ @shipping_speed = shipping_speed
68
+ @job_copies = job_copies
69
+ @job_full_bleed = job_full_bleed
70
+ @job_paper_id = job_paper_id
71
+ @job_finishing_option_id = job_finishing_option_id
72
+ @job_fold_across_long_edge = job_fold_across_long_edge
73
+ @job_front_imaging = job_front_imaging
74
+ @job_back_imaging = job_back_imaging
75
+ @job_flip_on_long_edge = job_flip_on_long_edge
76
+ @job_pages = job_pages
77
+ @panel_number = panel_number
78
+ @page_number = page_number
79
+ @rotation = rotation
80
+ end
81
+
82
+ base_uri "http://www.catprint.com"
83
+
84
+ def send_job(body)
85
+ self.class.post "/action_print", :body => { :email => @email,
86
+ :password => @password,
87
+ :action_print_job_xml => body }
88
+ end
89
+
90
+ def production_center_id
91
+ @production_center_id.nil? ? 1 : @production_center_id
92
+ end
93
+
94
+ def payment_method
95
+ @payment_method.nil? ? "pay_on_account" : @payment_method
96
+ end
97
+
98
+ def shipping_speed
99
+ @shipping_speed.nil? ? 7 : @shipping_speed
100
+ end
101
+
102
+ def job_copies
103
+ @job_copies.nil? ? 1 : @job_copies
104
+ end
105
+
106
+ def job_full_bleed
107
+ @job_full_bleed.nil? ? true : @job_full_bleed
108
+ end
109
+
110
+ def job_paper_id
111
+ @job_paper_id.nil? ? "HCS1SG" : @job_paper_id
112
+ end
113
+
114
+ def job_finishing_option_id
115
+ @job_finishing_option_id.nil? ? "1F" : @job_finishing_option_id
116
+ end
117
+
118
+ def job_fold_across_long_edge
119
+ @job_fold_across_long_edge.nil? ? true : @job_fold_across_long_edge
120
+ end
121
+
122
+ def job_front_imaging
123
+ @job_front_imaging.nil? ? "color" : @job_front_imaging
124
+ end
125
+
126
+ def job_back_imaging
127
+ @job_back_imaging.nil? ? "blank" : @job_back_imaging
128
+ end
129
+
130
+ def job_flip_on_long_edge
131
+ @job_flip_on_long_edge.nil? ? true : @job_flip_on_long_edge
132
+ end
133
+
134
+ def job_pages
135
+ @job_pages.nil? ? 1 : @job_pages
136
+ end
137
+
138
+ def panel_number
139
+ @panel_number.nil? ? 1 : @panel_number
140
+ end
141
+
142
+ def page_number
143
+ @page_number.nil? ? 1 : @page_number
144
+ end
145
+
146
+ def rotation
147
+ @rotation.nil? ? 0 : @rotation
148
+ end
149
+
150
+ def action_print_job_xml(*args)
151
+ action_print_job_xml = <<-EOF
152
+ <?xml version="1.0" encoding="UTF-8"?>
153
+ <action-print-job>
154
+ <production-center-id type="integer">#{@production_center_id}</production-center-id>
155
+ <submitter-id>#{@email}</submitter-id>
156
+ <submitter-password>#{@password}</submitter-password>
157
+ <payment-method>#{@payment_method}</payment-method>
158
+ <payment-amount>#{@payment_amount}</payment-amount>
159
+ <payment-profile-cc-expiration>#{@card_expiration}</payment-profile-cc-expiration>
160
+ <payment-profile-cc-number>#{@card_number}</payment-profile-cc-number>
161
+ <payment-profile-cc-type>#{@card_type}</payment-profile-cc-type>
162
+ <payment-profile-first-name>#{@card_holder_first_name}</payment-profile-first-name>
163
+ <payment-profile-last-name>#{@card_holder_last_name}</payment-profile-last-name>
164
+ <billing-company>#{@billing_company}</billing-company>
165
+ <billing-name>#{@billing_name}</billing-name>
166
+ <billing-address-1>#{@billing_address_1}</billing-address-1>
167
+ <billing-address-2>#{@billing_address_2}</billing-address-2>
168
+ <billing-city>#{@billing_city}</billing-city>
169
+ <billing-state>#{@billing_state}</billing-state>
170
+ <billing-zip>#{@billing_zip}</billing-zip>
171
+ <billing-country>#{@billing_country}</billing-country>
172
+ <billing-phone>#{@billing_phone}</billing-phone>
173
+ <shipping-company>#{@shipping_company}</shipping-company>
174
+ <shipping-name>#{@shipping_name}</shipping-name>
175
+ <shipping-address-1>#{@shipping_address_1}</shipping-address-1>
176
+ <shipping-address-2>#{@shipping_address_2}</shipping-address-2>
177
+ <shipping-city>#{@shipping_city}</shipping-city>
178
+ <shipping-state>#{@shipping_state}</shipping-state>
179
+ <shipping-zip>#{@shipping_zip}</shipping-zip>
180
+ <shipping-country>#{@shipping_country}</shipping-country>
181
+ <shipping-phone>#{@shipping_phone}</shipping-phone>
182
+ <shipping-speed>#{@shipping_speed}</shipping-speed>
183
+ <shipping-instructions>#{@shipping_instructions}</shipping-instructions>
184
+ <drop-ship-company>#{@drop_ship_company}</drop-ship-company>
185
+ <drop-ship-address-1>#{@drop_ship_address_1}</drop-ship-address-1>
186
+ <drop-ship-address-2>#{@drop_ship_address_2}</drop-ship-address-2>
187
+ <drop-ship-city>#{@drop_ship_city}</drop-ship-city>
188
+ <drop-ship-state>#{@drop_ship_state}</drop-ship-state>
189
+ <drop-ship-zip>#{@drop_ship_zip}</drop-ship-zip>
190
+ <drop-ship-country>#{@drop_ship_country}</drop-ship-country>
191
+ <drop-ship-phone>#{@drop_ship_phone}</drop-ship-phone>
192
+ <drop-ship-packing-slip-url>#{@drop_ship_packing_slip_url}</drop-ship-packing-slip-url>
193
+ <jobs type="array">
194
+ <job>
195
+ <name>#{@job_name}</name>
196
+ <copies>#{@job_copies}</copies>
197
+ <width>#{@job_width}</width>
198
+ <height>#{@job_height}</height>
199
+ <full-bleed>#{@job_full_bleed}</full-bleed>
200
+ <paper-id>#{@job_paper_id}</paper-id>
201
+ <envelope-id>#{@job_envelope_id}</envelope-id>
202
+ <finishing-option-id>#{@job_finishing_option_id}</finishing-option-id>
203
+ <fold-across-long-edge>#{@job_fold_across_long_edge}</fold-across-long-edge>
204
+ <front-imaging>#{@job_front_imaging}</front-imaging>
205
+ <back-imaging>#{@job_back_imaging}</back-imaging>
206
+ <flip-on-long-edge>#{@job_flip_on_long_edge}</flip-on-long-edge>
207
+ <pages>#{@job_pages}</pages>
208
+ <panels type="array">
209
+ <panel>
210
+ <panel-source-file>#{@panel_source_file}</panel-source-file>
211
+ <panel-number>#{@panel_number}</panel-number>
212
+ <page-number>#{@page_number}</page-number>
213
+ <rotation>#{@rotation}</rotation>
214
+ </panel>
215
+ </panels>
216
+ </job>
217
+ </jobs>
218
+ </action-print-job>
219
+ EOF
220
+ end
221
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "lib/catprint"
3
+
4
+ class TestCatPrint < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: catprint
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Bryan Woods
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-17 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: httparty
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 6
30
+ - 1
31
+ version: 0.6.1
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Ruby wrapper for the CatPrint API
35
+ email: bryanwoods4e@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - catprint.gemspec
44
+ - example/sinatra_app.rb
45
+ - lib/catprint.rb
46
+ - README.md
47
+ - test/test_catprint.rb
48
+ has_rdoc: true
49
+ homepage: http://github.com/bryanwoods/catprint
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options: []
54
+
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project: catprint
74
+ rubygems_version: 1.3.6
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Allows Ruby developers to interact with CatPrint's ActionPrint API (http://www.catprint.com/action_print) with pure Ruby.
78
+ test_files: []
79
+