archerfinley-google4r-checkout-1.0.5 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/CHANGES +93 -0
  2. data/LICENSE +22 -0
  3. data/README +58 -0
  4. data/Rakefile +13 -0
  5. data/VERSION +1 -0
  6. data/google4r-checkout-1.0.5-1.0.5.gem +0 -0
  7. data/google4r-checkout-1.0.5.gemspec +174 -0
  8. data/lib/google4r/checkout.rb +34 -0
  9. data/lib/google4r/checkout/commands.rb +567 -0
  10. data/lib/google4r/checkout/frontend.rb +210 -0
  11. data/lib/google4r/checkout/merchant_calculation.rb +321 -0
  12. data/lib/google4r/checkout/notifications.rb +708 -0
  13. data/lib/google4r/checkout/shared.rb +1086 -0
  14. data/lib/google4r/checkout/utils.rb +94 -0
  15. data/lib/google4r/checkout/xml_generation.rb +880 -0
  16. data/test/integration/checkout_command_test.rb +174 -0
  17. data/test/unit/add_merchant_order_number_command_test.rb +70 -0
  18. data/test/unit/add_tracking_data_command_test.rb +75 -0
  19. data/test/unit/address_test.rb +131 -0
  20. data/test/unit/anonymous_address_test.rb +75 -0
  21. data/test/unit/archive_order_command_test.rb +66 -0
  22. data/test/unit/area_test.rb +44 -0
  23. data/test/unit/authorization_amount_notification_test.rb +69 -0
  24. data/test/unit/authorize_order_command_test.rb +66 -0
  25. data/test/unit/backorder_items_command_test.rb +83 -0
  26. data/test/unit/callback_handler_test.rb +83 -0
  27. data/test/unit/cancel_items_command_test.rb +89 -0
  28. data/test/unit/cancel_order_command_test.rb +83 -0
  29. data/test/unit/carrier_calculated_shipping_test.rb +57 -0
  30. data/test/unit/charge_amount_notification_test.rb +64 -0
  31. data/test/unit/charge_order_command_test.rb +77 -0
  32. data/test/unit/chargeback_amount_notification_test.rb +65 -0
  33. data/test/unit/checkout_command_test.rb +125 -0
  34. data/test/unit/checkout_command_xml_generator_test.rb +218 -0
  35. data/test/unit/command_test.rb +116 -0
  36. data/test/unit/deliver_order_command_test.rb +70 -0
  37. data/test/unit/delivery_method_test.rb +42 -0
  38. data/test/unit/digital_content_test.rb +105 -0
  39. data/test/unit/flat_rate_shipping_test.rb +132 -0
  40. data/test/unit/frontend_test.rb +144 -0
  41. data/test/unit/item_info_test.rb +69 -0
  42. data/test/unit/item_test.rb +171 -0
  43. data/test/unit/marketing_preferences_test.rb +65 -0
  44. data/test/unit/merchant_calculated_shipping_test.rb +172 -0
  45. data/test/unit/merchant_calculation_callback_test.rb +137 -0
  46. data/test/unit/merchant_calculation_result_test.rb +78 -0
  47. data/test/unit/merchant_calculation_results_test.rb +178 -0
  48. data/test/unit/merchant_code_result_test.rb +51 -0
  49. data/test/unit/merchant_code_test.rb +122 -0
  50. data/test/unit/new_order_notification_test.rb +115 -0
  51. data/test/unit/notification_acknowledgement_test.rb +67 -0
  52. data/test/unit/notification_handler_test.rb +113 -0
  53. data/test/unit/order_adjustment_test.rb +119 -0
  54. data/test/unit/order_report_command_test.rb +111 -0
  55. data/test/unit/order_state_change_notification_test.rb +158 -0
  56. data/test/unit/pickup_shipping_test.rb +70 -0
  57. data/test/unit/postal_area_test.rb +71 -0
  58. data/test/unit/private_data_parser_test.rb +68 -0
  59. data/test/unit/refund_amount_notification_test.rb +65 -0
  60. data/test/unit/refund_order_command_test.rb +86 -0
  61. data/test/unit/reset_items_shipping_information_command_test.rb +83 -0
  62. data/test/unit/return_items_command_test.rb +83 -0
  63. data/test/unit/risk_information_notification_test.rb +98 -0
  64. data/test/unit/send_buyer_message_command_test.rb +73 -0
  65. data/test/unit/ship_items_command_test.rb +101 -0
  66. data/test/unit/shipping_adjustment_test.rb +100 -0
  67. data/test/unit/shopping_cart_test.rb +146 -0
  68. data/test/unit/tax_rule_test.rb +70 -0
  69. data/test/unit/tax_table_test.rb +82 -0
  70. data/test/unit/tracking_data_test.rb +54 -0
  71. data/test/unit/unarchive_order_command_test.rb +66 -0
  72. data/test/unit/us_country_area_test.rb +76 -0
  73. data/test/unit/us_state_area_test.rb +70 -0
  74. data/test/unit/us_zip_area_test.rb +66 -0
  75. data/test/unit/world_area_test.rb +48 -0
  76. data/var/cacert.pem +7815 -0
  77. metadata +189 -0
data/CHANGES ADDED
@@ -0,0 +1,93 @@
1
+ =google4r-checkout Changelog
2
+
3
+ == 1.0.5 (2008-9-17)
4
+
5
+ * Added Order Report API support. Thanks to Daniel Pirone!
6
+ * Added unit tests for OrderReportCommand. Added validation checks fro start_date, end_date, financial_state and fulfillment_state.
7
+
8
+ == 1.0.4 (2008-09-02)
9
+
10
+ * Fixed undefined email_delivery? method bug
11
+ * Added unit test to cover digital content creation
12
+
13
+ == 1.0.3 (2008-08-08)
14
+
15
+ * Added analytics_data support. Thanks to Will Schwenk!
16
+ * Added create_address_filters_allowed_area and create_address_filters_excluded_area method to the MerchantCalculatedShipping class.
17
+ * Created two aliases create_shipping_restrictions_allowed_area and create_shipping_restrictions_excluded_area to facilitate deprecation of create_allowed_area and create_excluded_area.
18
+ * country_code in PostalArea class is now optional in the initialize method so it can be called properly in the create_area method in shared.rb.
19
+ * Added line-item shipping support.
20
+ * Refactor notifications to extract a base notification class that has the front_end, serial_number, google_order_number and timestamp.
21
+ * Added notification handshake support (i.e. serial-number) for notifciation-acknowledgement.
22
+ * Added digital delivery support. Thanks to Andy Kim and Matthew Moore!
23
+ * Added Carrier Calculated Shipping support.
24
+ * Added unit tests - carrier_calculated_shipping_test.rb, digital_content_test.rb, *_items_*commands.rb
25
+ * Updated unit tests - item_test.rb, merchant_calculated_shipping_test.rb, notification_acknowledgement_test.rb
26
+ * Updated integration test - checkout_command_test.rb
27
+ * Added HTML Form API Signature support. It is included in utils.rb.
28
+
29
+ == 1.0.2 (2007-08-18)
30
+
31
+ * Moved Address from notifications.rb to shared.rb
32
+ * Added AnonymousAddress class, now Address is extended from it
33
+ * Added merchant calcuations callback and result support
34
+ * Added unit tests for merchant calculation callback and result
35
+ * Added merchant calculations tag support in Shopping Cart XML
36
+ * Updated checkout_command_test.rb and checkout_command_xml_generator_test.rb after for testing merchant calculations tag support
37
+
38
+ == 1.0.1 (2007-08-16)
39
+
40
+ * Fixed text.to_s.gsub(/[^0-9]/, '') to (...text.to_f*100).to_i so dollar amount is now handled correctly
41
+
42
+ == 1.0.0 (2007-08-04)
43
+
44
+ * Added refund-amount-notification
45
+ * Added chargeback-amount-notification
46
+ * Added authorization-amount-notification
47
+ * Added refund command
48
+ * Added authorize command
49
+ * Added add-merchant-number command
50
+ * Added add-tracking-data command
51
+ * Added send-buyer-message command
52
+ * Added archive-order command
53
+ * Added unarchive-order command
54
+ * Refactored to_xml in the Command class
55
+ * Added CommandXmlGenerator base class
56
+ * Added ChargeOrderCommand, DeliverOrderCommand, CancelOrderCommand, ChargeAmountNotification and RiskInfoNotification (all contributed by Dan Dukeson).
57
+ * Attributes are not retrieved via XPaths with "tag/@attribute" any more but with REXML's Element#attributes. This should fix problems with Ruby 1.8.6.
58
+
59
+ == 0.1.0 (2007-05-12)
60
+ * Added property "shipping_taxed" to TaxRule (contributed by Dan Dukeson).
61
+ * Added XML generation for the tax tables in the shopping cart (contributed by Dan Dukeson).
62
+ * Added Area subclasses WorldArea and PostalArea (contributed by Dan Dukeson).
63
+ * Changed time zones in tests to UTC.
64
+ * Added Test::Unit::TestCase#assert_strings_equal to test_helper.rb.
65
+ * Added "rake test" (alias of "rake test:all")
66
+ * Added GoogleCheckoutError#to_s to return verbose representation.
67
+ * Split google4r into google4r-checkout and google4r-maps.
68
+ * MerchantCode#create_from_element raises an ArgumentError instead of a RuntimeError on invalid elements now.
69
+ * Changed the #create_from_element code to set the properties directly into the objects instead of building Hashes to collect the values first.
70
+ * "Resolved" the problem of converting currency amounts which are fractional numbers into the amount of the minor currency to be passed into the Money class: Instead of converting the fractional number into a float and multiplying by 100, all nonnumeric characters are stripped from the string, the resulting number is converted into an integer and this integer is then passed to Money.new.
71
+ * Added example to NotificationHandler of how to use the class.
72
+ * Added link to simple_http_auth plugin in NotificationHandler which allows for easy HTTP Auth Basic protection of Rails controllers.
73
+ * Renamed CheckoutCommand#cart to CheckoutCommand#shopping_cart
74
+ * CheckoutCommand raises ArgumentError instead of RuntimeError on invalid clazz parameter.
75
+ * Added "Howto freeze google4r in a Rails project" to README
76
+ * Google4R::Checkout::Command#to_xml raises an NotImplementedError instead of a RuntimeError now.
77
+ * Geocoder returns nil on 603 (G_UNAVAILABLE_ADDRESS) results now.
78
+ * Added support for registering GUnload() to be called on window's unload event.
79
+ * The generated Javascript that creates the GMap2() instance (and thus modifies the map div) has been put into a function <var name>_loader that is called in an onload handler. This should remove a problem with MSIE.
80
+ * Using Syck as the YAML parser now. However, a workaround is needed because of http://code.whytheluckystiff.net/syck/ticket/27.
81
+ * Only require the json gem if objects have no "to_json" method already added to them. This solves a problem with converting arbitrary objects to json because the json gem seemingly only converts simple types.
82
+ * Added GMarker#info_window_html.
83
+ * Added support for onclick handlers in markers.
84
+ * Added support for the value :auto of GMap2#zoom and GMap2#center.
85
+ * Fixed buggy generation of GMarker Javascript.
86
+ * Adding website folder to contain a webgen based website.
87
+ * Fixed a problem with generating XML from Hashes in the "private" data of shopping carts and items.
88
+ * The parse for the <order-adjustment> tag does not expect to see a <shipping> tag in every case any more.
89
+ * Extending Google4R::Maps by the classes GMap2, GIcon and GMarker to allow for easy Google Maps HTML generation.
90
+
91
+ == 0.0.1 (2007-02-17)
92
+
93
+ * initial release, be prepared for some API changes that move the API closer to the XML API
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Unless noted otherwise, the files of this projects are licensed under a MIT
2
+ style license:
3
+
4
+ Copyright (c) 2007 Manuel Holtgrewe
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to
8
+ deal in the Software without restriction, including without limitation the
9
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ sell copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
+ IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,58 @@
1
+ = google4r/checkout
2
+
3
+ google4r/checkout is a library to access the Google Checkout API.
4
+
5
+ === License
6
+
7
+ google4r itself is distributed under an MIT style license.
8
+
9
+ However, the library includes the cacert.pem:http://curl.haxx.se/ca/cacert.pem file from the Mozilla project. This file is distributed under the MPL:http://www.mozilla.org/MPL/.
10
+
11
+ == More Information
12
+
13
+ You can find more information on the Google Checkout API here:http://code.google.com/apis/checkout/developer/index.html. Note that the API documentation assumes an understanding of the Google Checkout XML API.
14
+
15
+ == Google Checkout Tests
16
+
17
+ You have to place a file called 'frontend_configuration.rb' in the directory'test' with the configuration for the Google4R::Checkout::Frontend class to use for running the tests.
18
+
19
+ The file should contain content similar to:
20
+
21
+ # Uncomment the following line if you are using Google Checkout in Great Britain
22
+ # and adjust it if you want to test google4r-checkout against any other (future)
23
+ # Google Checkout service.
24
+
25
+ # Money.default_currency = 'GBP'
26
+
27
+ # The test configuration for the Google4R::Checkout::Frontend class.
28
+ FRONTEND_CONFIGURATION =
29
+ {
30
+ :merchant_id => '<your merchant id>',
31
+ :merchant_key => '<your merchant key>',
32
+ :use_sandbox => true
33
+ }
34
+
35
+ == Dependencies
36
+
37
+ The unit tests use Mocha so you have to install the gem "mocha" to run the tests. You will also need the money gem library.
38
+
39
+ == How To: Freeze a google4r version in a Rails project
40
+
41
+ <code>rake rails:freeze:gems</code> only works for the Rails gems. So, how do you freeze your own gems like google4r? It turns out to be pretty straightforward:
42
+
43
+ cd RAILS_ROOT
44
+ cd vendor
45
+ gem unpack google4r-checkout
46
+ ls
47
+ # ... google4r-checkout-0.1.1 ...
48
+
49
+ Then, open RAILS_ROOT/config/environment.rb in your favourite text editor and add the following lines at the top of the file just below <code>require File.join(File.dirname(__FILE__), 'boot')</code>:
50
+
51
+ # Freeze non-Rails gem.
52
+ Dir.glob(File.join(RAILS_ROOT, 'vendor', '*', 'lib')) do |path|
53
+ $LOAD_PATH << path
54
+ end
55
+
56
+ Now you can use the following in your own code:
57
+
58
+ require 'google4r/checkout'
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "google4r-checkout-1.0.5"
5
+ gemspec.summary = "Google Checkout API Gem"
6
+ gemspec.description = "This gem aids in integrating the Google Checkout API with your existing rails site"
7
+ gemspec.email = "archer@interknown.com"
8
+ gemspec.homepage = "http://code.google.com/p/google-checkout-ruby-sample-code/"
9
+ gemspec.authors = ["api.htchan, api.jkleinert"]
10
+ end
11
+ rescue LoadError
12
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
13
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.5
@@ -0,0 +1,174 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{google4r-checkout-1.0.5}
8
+ s.version = "1.0.5"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["api.htchan, api.jkleinert"]
12
+ s.date = %q{2009-08-13}
13
+ s.description = %q{This gem aids in integrating the Google Checkout API with your existing rails site}
14
+ s.email = %q{archer@interknown.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README"
18
+ ]
19
+ s.files = [
20
+ "CHANGES",
21
+ "LICENSE",
22
+ "README",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "google4r-checkout-1.0.5-1.0.5.gem",
26
+ "google4r-checkout-1.0.5.gemspec",
27
+ "lib/google4r/checkout.rb",
28
+ "lib/google4r/checkout/commands.rb",
29
+ "lib/google4r/checkout/frontend.rb",
30
+ "lib/google4r/checkout/merchant_calculation.rb",
31
+ "lib/google4r/checkout/notifications.rb",
32
+ "lib/google4r/checkout/shared.rb",
33
+ "lib/google4r/checkout/utils.rb",
34
+ "lib/google4r/checkout/xml_generation.rb",
35
+ "test/integration/checkout_command_test.rb",
36
+ "test/unit/add_merchant_order_number_command_test.rb",
37
+ "test/unit/add_tracking_data_command_test.rb",
38
+ "test/unit/address_test.rb",
39
+ "test/unit/anonymous_address_test.rb",
40
+ "test/unit/archive_order_command_test.rb",
41
+ "test/unit/area_test.rb",
42
+ "test/unit/authorization_amount_notification_test.rb",
43
+ "test/unit/authorize_order_command_test.rb",
44
+ "test/unit/backorder_items_command_test.rb",
45
+ "test/unit/callback_handler_test.rb",
46
+ "test/unit/cancel_items_command_test.rb",
47
+ "test/unit/cancel_order_command_test.rb",
48
+ "test/unit/carrier_calculated_shipping_test.rb",
49
+ "test/unit/charge_amount_notification_test.rb",
50
+ "test/unit/charge_order_command_test.rb",
51
+ "test/unit/chargeback_amount_notification_test.rb",
52
+ "test/unit/checkout_command_test.rb",
53
+ "test/unit/checkout_command_xml_generator_test.rb",
54
+ "test/unit/command_test.rb",
55
+ "test/unit/deliver_order_command_test.rb",
56
+ "test/unit/delivery_method_test.rb",
57
+ "test/unit/digital_content_test.rb",
58
+ "test/unit/flat_rate_shipping_test.rb",
59
+ "test/unit/frontend_test.rb",
60
+ "test/unit/item_info_test.rb",
61
+ "test/unit/item_test.rb",
62
+ "test/unit/marketing_preferences_test.rb",
63
+ "test/unit/merchant_calculated_shipping_test.rb",
64
+ "test/unit/merchant_calculation_callback_test.rb",
65
+ "test/unit/merchant_calculation_result_test.rb",
66
+ "test/unit/merchant_calculation_results_test.rb",
67
+ "test/unit/merchant_code_result_test.rb",
68
+ "test/unit/merchant_code_test.rb",
69
+ "test/unit/new_order_notification_test.rb",
70
+ "test/unit/notification_acknowledgement_test.rb",
71
+ "test/unit/notification_handler_test.rb",
72
+ "test/unit/order_adjustment_test.rb",
73
+ "test/unit/order_report_command_test.rb",
74
+ "test/unit/order_state_change_notification_test.rb",
75
+ "test/unit/pickup_shipping_test.rb",
76
+ "test/unit/postal_area_test.rb",
77
+ "test/unit/private_data_parser_test.rb",
78
+ "test/unit/refund_amount_notification_test.rb",
79
+ "test/unit/refund_order_command_test.rb",
80
+ "test/unit/reset_items_shipping_information_command_test.rb",
81
+ "test/unit/return_items_command_test.rb",
82
+ "test/unit/risk_information_notification_test.rb",
83
+ "test/unit/send_buyer_message_command_test.rb",
84
+ "test/unit/ship_items_command_test.rb",
85
+ "test/unit/shipping_adjustment_test.rb",
86
+ "test/unit/shopping_cart_test.rb",
87
+ "test/unit/tax_rule_test.rb",
88
+ "test/unit/tax_table_test.rb",
89
+ "test/unit/tracking_data_test.rb",
90
+ "test/unit/unarchive_order_command_test.rb",
91
+ "test/unit/us_country_area_test.rb",
92
+ "test/unit/us_state_area_test.rb",
93
+ "test/unit/us_zip_area_test.rb",
94
+ "test/unit/world_area_test.rb",
95
+ "var/cacert.pem"
96
+ ]
97
+ s.homepage = %q{http://code.google.com/p/google-checkout-ruby-sample-code/}
98
+ s.rdoc_options = ["--charset=UTF-8"]
99
+ s.require_paths = ["lib"]
100
+ s.rubygems_version = %q{1.3.4}
101
+ s.summary = %q{Google Checkout API Gem}
102
+ s.test_files = [
103
+ "test/integration/checkout_command_test.rb",
104
+ "test/unit/send_buyer_message_command_test.rb",
105
+ "test/unit/authorization_amount_notification_test.rb",
106
+ "test/unit/add_tracking_data_command_test.rb",
107
+ "test/unit/charge_amount_notification_test.rb",
108
+ "test/unit/charge_order_command_test.rb",
109
+ "test/unit/ship_items_command_test.rb",
110
+ "test/unit/shopping_cart_test.rb",
111
+ "test/unit/new_order_notification_test.rb",
112
+ "test/unit/refund_amount_notification_test.rb",
113
+ "test/unit/us_state_area_test.rb",
114
+ "test/unit/world_area_test.rb",
115
+ "test/unit/carrier_calculated_shipping_test.rb",
116
+ "test/unit/merchant_code_test.rb",
117
+ "test/unit/flat_rate_shipping_test.rb",
118
+ "test/unit/us_zip_area_test.rb",
119
+ "test/unit/address_test.rb",
120
+ "test/unit/merchant_code_result_test.rb",
121
+ "test/unit/tracking_data_test.rb",
122
+ "test/unit/cancel_items_command_test.rb",
123
+ "test/unit/area_test.rb",
124
+ "test/unit/us_country_area_test.rb",
125
+ "test/unit/marketing_preferences_test.rb",
126
+ "test/unit/pickup_shipping_test.rb",
127
+ "test/unit/merchant_calculated_shipping_test.rb",
128
+ "test/unit/authorize_order_command_test.rb",
129
+ "test/unit/postal_area_test.rb",
130
+ "test/unit/shipping_adjustment_test.rb",
131
+ "test/unit/anonymous_address_test.rb",
132
+ "test/unit/backorder_items_command_test.rb",
133
+ "test/unit/tax_table_test.rb",
134
+ "test/unit/order_report_command_test.rb",
135
+ "test/unit/command_test.rb",
136
+ "test/unit/unarchive_order_command_test.rb",
137
+ "test/unit/digital_content_test.rb",
138
+ "test/unit/reset_items_shipping_information_command_test.rb",
139
+ "test/unit/risk_information_notification_test.rb",
140
+ "test/unit/delivery_method_test.rb",
141
+ "test/unit/chargeback_amount_notification_test.rb",
142
+ "test/unit/return_items_command_test.rb",
143
+ "test/unit/callback_handler_test.rb",
144
+ "test/unit/merchant_calculation_callback_test.rb",
145
+ "test/unit/checkout_command_test.rb",
146
+ "test/unit/order_adjustment_test.rb",
147
+ "test/unit/tax_rule_test.rb",
148
+ "test/unit/item_info_test.rb",
149
+ "test/unit/merchant_calculation_results_test.rb",
150
+ "test/unit/cancel_order_command_test.rb",
151
+ "test/unit/merchant_calculation_result_test.rb",
152
+ "test/unit/item_test.rb",
153
+ "test/unit/deliver_order_command_test.rb",
154
+ "test/unit/checkout_command_xml_generator_test.rb",
155
+ "test/unit/private_data_parser_test.rb",
156
+ "test/unit/refund_order_command_test.rb",
157
+ "test/unit/order_state_change_notification_test.rb",
158
+ "test/unit/frontend_test.rb",
159
+ "test/unit/archive_order_command_test.rb",
160
+ "test/unit/notification_acknowledgement_test.rb",
161
+ "test/unit/add_merchant_order_number_command_test.rb",
162
+ "test/unit/notification_handler_test.rb"
163
+ ]
164
+
165
+ if s.respond_to? :specification_version then
166
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
167
+ s.specification_version = 3
168
+
169
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
170
+ else
171
+ end
172
+ else
173
+ end
174
+ end
@@ -0,0 +1,34 @@
1
+ #--
2
+ # Project: google4r
3
+ # File: lib/google4r/checkout.rb
4
+ # Author: Manuel Holtgrewe <purestorm at ggnore dot net>
5
+ # Copyright: (c) 2007 by Manuel Holtgrewe
6
+ # License: MIT License as follows:
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining
9
+ # a copy of this software and associated documentation files (the
10
+ # "Software"), to deal in the Software without restriction, including
11
+ # without limitation the rights to use, copy, modify, merge, publish,
12
+ # distribute, sublicense, and/or sell copies of the Software, and to permit
13
+ # persons to whom the Software is furnished to do so, subject to the
14
+ # following conditions:
15
+ #
16
+ # The above copyright notice and this permission notice shall be included
17
+ # in all copies or substantial portions of the Software.
18
+ #
19
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
25
+ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ #++
27
+ # Require all the files that provide the code for the Google Checkout wrapper.
28
+
29
+ require 'google4r/checkout/shared'
30
+ require 'google4r/checkout/commands'
31
+ require 'google4r/checkout/notifications'
32
+ require 'google4r/checkout/xml_generation'
33
+ require 'google4r/checkout/frontend'
34
+ require 'google4r/checkout/merchant_calculation'
@@ -0,0 +1,567 @@
1
+ #--
2
+ # Project: google4r
3
+ # File: lib/google4r/checkout/commands.rb
4
+ # Author: Manuel Holtgrewe <purestorm at ggnore dot net>
5
+ # Copyright: (c) 2007 by Manuel Holtgrewe
6
+ # License: MIT License as follows:
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining
9
+ # a copy of this software and associated documentation files (the
10
+ # "Software"), to deal in the Software without restriction, including
11
+ # without limitation the rights to use, copy, modify, merge, publish,
12
+ # distribute, sublicense, and/or sell copies of the Software, and to permit
13
+ # persons to whom the Software is furnished to do so, subject to the
14
+ # following conditions:
15
+ #
16
+ # The above copyright notice and this permission notice shall be included
17
+ # in all copies or substantial portions of the Software.
18
+ #
19
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
25
+ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ #++
27
+ # This file contains the classes and modules that are used by the command
28
+ # generating code.
29
+
30
+ require 'openssl'
31
+ require 'money'
32
+ require 'net/http'
33
+ require 'net/https'
34
+ require 'uri'
35
+
36
+ module Google4R #:nodoc:
37
+ module Checkout #:nodoc:
38
+ # Abstract super class for all commands that are to be sent to Google. Provides the base
39
+ # functionality for signing and encoding the cart.
40
+ class Command
41
+ # The URL to use for requests to the sandboxed API. The merchant id is to be
42
+ # put in via String#%.
43
+ SANDBOX_URL_PREFIX = 'https://sandbox.google.com/checkout/'
44
+
45
+ # The URL to use for real requests to the Google Checkout API. The merchant id
46
+ # is to be put in via String#%.
47
+ PRODUCTION_URL_PREFIX = 'https://checkout.google.com/'
48
+
49
+ CHECKOUT_API_URL = 'api/checkout/v2/merchantCheckout/Merchant/%s'
50
+
51
+ ORDER_PROCESSING_API_URL = 'api/checkout/v2/request/Merchant/%s'
52
+
53
+ ORDER_REPORT_API_URL = 'api/checkout/v2/reports/Merchant/%s'
54
+
55
+
56
+ # The Frontent class that was used to create this CheckoutCommand and whose
57
+ # configuration will be used.
58
+ attr_reader :frontend
59
+
60
+ # The tag name of the command
61
+ attr_reader :command_tag_name
62
+
63
+ # The google order number, required, String
64
+ attr_accessor :google_order_number
65
+
66
+ # Initialize the frontend attribute with the value of the frontend parameter.
67
+ def initialize(frontend)
68
+ if self.instance_of?(Command) || self.instance_of?(ItemsCommand)
69
+ raise 'Cannot instantiate abstract class ' + self.class.to_s
70
+ end
71
+ @frontend = frontend
72
+ end
73
+
74
+ # Sends the cart's XML to GoogleCheckout via HTTPs with Basic Auth.
75
+ #
76
+ # Raises an OpenSSL::SSL::SSLError when the SSL certificate verification failed.
77
+ #
78
+ # Raises a GoogleCheckoutError when Google returns an error.
79
+ #
80
+ # Raises a RuntimeException on unknown responses.
81
+ #--
82
+ # TODO: The send-and-expect-response part should be adaptable to other commands and responses.
83
+ #++
84
+ def send_to_google_checkout
85
+ xml_response = (self.class == OrderReportCommand) ? false : true
86
+ # Create HTTP(S) POST command and set up Basic Authentication.
87
+ url_str =
88
+ if frontend.configuration[:use_sandbox] then
89
+ SANDBOX_URL_PREFIX
90
+ else
91
+ PRODUCTION_URL_PREFIX
92
+ end
93
+ url_str +=
94
+ if self.class == CheckoutCommand then
95
+ CHECKOUT_API_URL
96
+ elsif self.class == OrderReportCommand then
97
+ ORDER_REPORT_API_URL
98
+ else
99
+ ORDER_PROCESSING_API_URL
100
+ end
101
+ url_str = url_str % frontend.configuration[:merchant_id]
102
+ url = URI.parse(url_str)
103
+
104
+ request = Net::HTTP::Post.new(url.path)
105
+ request.basic_auth(frontend.configuration[:merchant_id], frontend.configuration[:merchant_key])
106
+
107
+ # Set up the HTTP connection object and the SSL layer.
108
+ https = Net::HTTP.new(url.host, url.port)
109
+ https.use_ssl = true
110
+ https.cert_store = self.class.x509_store
111
+ https.verify_mode = OpenSSL::SSL::VERIFY_PEER
112
+ https.verify_depth = 5
113
+
114
+ # Send the request to Google.
115
+ result = https.request(request, self.to_xml)
116
+
117
+ case result
118
+ when Net::HTTPSuccess then
119
+ if ( xml_response ) then
120
+ xml_doc = REXML::Document.new(result.body)
121
+
122
+ case xml_doc.root.name
123
+ when 'checkout-redirect'
124
+ serial_number = xml_doc.elements['/checkout-redirect'].attributes['serial-number']
125
+ redirect_url = xml_doc.elements['/checkout-redirect/redirect-url/text()'].value
126
+ return CheckoutRedirectResponse.new(serial_number, redirect_url)
127
+ when 'request-received'
128
+ serial_number = xml_doc.elements['/request-received'].attributes['serial-number']
129
+ return serial_number
130
+ else
131
+ raise "Unknown response:\n--\n#{xml_doc.to_s}\n--"
132
+ end
133
+ else
134
+ # handle the CSV output of the order-report-list command
135
+ return result.body
136
+ end
137
+ when Net::HTTPClientError then
138
+ xml_doc = REXML::Document.new(result.body)
139
+
140
+ if xml_doc.elements['/error'].attributes['serial-number'].nil? or xml_doc.elements['/error/error-message/text()'].nil? then
141
+ raise "Invalid response from Google:\n---\n#{result.body}\n---"
142
+ end
143
+
144
+ hash =
145
+ {
146
+ :serial_number => xml_doc.elements['/error'].attributes['serial-number'],
147
+ :message => xml_doc.elements['/error/error-message/text()'].value
148
+ }
149
+
150
+ raise GoogleCheckoutError.new(hash)
151
+ when Net::HTTPRedirection, Net::HTTPServerError, Net::HTTPInformation then
152
+ raise "Unexpected reponse code (#{result.class}): #{result.code} - #{result.message}"
153
+ else
154
+ raise "Unknown reponse code: #{result.code} - #{result.message}"
155
+ end
156
+ end
157
+
158
+ # Class method to return the command's XML representation.
159
+ def to_xml
160
+ generator_class = Google4R::Command.get_const("#{self.class}XmlGenerator")
161
+ return generator_class.new(self).generate
162
+ end
163
+
164
+ protected
165
+
166
+ # Class method to return the OpenSSL::X509::Store instance for the
167
+ # CA certificates.
168
+ #--
169
+ # TODO: Is OpenSSL::X509::Store thread safe when reading only? This method most certainly is *not*. It must become so.
170
+ #++
171
+ def self.x509_store
172
+ return @@x509_store if defined?(@@x509_store)
173
+
174
+ cacert_path = File.expand_path(File.dirname(__FILE__) + '/../../../var/cacert.pem')
175
+
176
+ @@x509_store = OpenSSL::X509::Store.new
177
+ @@x509_store.add_file(cacert_path)
178
+
179
+ return @@x509_store
180
+ end
181
+ end
182
+
183
+ # The CheckoutCommand represents a <checkout-shopping-cart> command sent
184
+ # to the server.
185
+ #
186
+ # A CheckoutCommand instance can have an arbitrary number of TaxTable
187
+ # and ShippingMethod instances. You must create these instances using the
188
+ # create_* methods which CheckoutCommand supplies.
189
+ #
190
+ # CheckoutCommand#send_to_google_checkout returns CheckoutRedirectResponse
191
+ # instances.
192
+ #
193
+ # Use the Frontend class to create new CheckoutCommand instances and do not
194
+ # instanciate the class directly.
195
+ #
196
+ # Note that you have to create/set the tax tables for CheckoutCommands before you
197
+ # can add any items to the cart that define a tax table.
198
+ #
199
+ # === Example
200
+ #
201
+ # frontend = Google4R::Checkout::Frontend.new(configuration)
202
+ # frontend.tax_table_factory = TaxTableFactory.new
203
+ # command = frontend.create_checkout_command
204
+ class CheckoutCommand < Command
205
+ # The ShoppingCart of this CheckoutCommand.
206
+ attr_reader :shopping_cart
207
+
208
+ # An array of the TaxTable objects of this CheckoutCommand. They have been
209
+ # created with the tax table factory of the frontend which created this
210
+ # command.
211
+ attr_reader :tax_tables
212
+
213
+ # An array of ShippingMethod objects of this CheckoutCommand. Use
214
+ # #create_shipping_method to create new shipping methods.
215
+ attr_reader :shipping_methods
216
+
217
+ # The URL at where the cart can be edited (String, optional).
218
+ attr_accessor :edit_cart_url
219
+
220
+ # The URL to continue shopping after completing the checkout (String, optional).
221
+ attr_accessor :continue_shopping_url
222
+
223
+ # A boolean flag; true iff the customer HAS to provide his phone number (optional).
224
+ attr_accessor :request_buyer_phone_number
225
+
226
+ # The URL of the merchant calculation callback (optional).
227
+ attr_accessor :merchant_calculations_url
228
+
229
+ # A boolean flag to indicate whether merchant coupon is supported or not (optional).
230
+ attr_accessor :accept_merchant_coupons
231
+
232
+ # A boolean flag to indicate whether gift certificate is supported or not (optional).
233
+ attr_accessor :accept_gift_certificates
234
+
235
+ # A Google Checkout merchant ID that identifies the eCommerce provider.
236
+ attr_accessor :platform_id
237
+
238
+ # Setting this allows Google Analytics to track purchases that use Checkout
239
+ # The value should be as set by the analytics javascript in the hidden form
240
+ # element names "analyticsdata" on the page with the checkout button.
241
+ # If left unset then the element will not be generated.
242
+ # see: http://code.google.com/apis/checkout/developer/checkout_analytics_integration.html
243
+ attr_accessor :analytics_data
244
+
245
+ # Generates the XML for this CheckoutCommand.
246
+ def to_xml
247
+ CheckoutCommandXmlGenerator.new(self).generate
248
+ end
249
+
250
+ # Initialize a new CheckoutCommand with a fresh CheckoutCart and an empty
251
+ # Array of tax tables and an empty array of ShippingMethod instances.
252
+ # Do not use this method directly but use Frontent#create_checkout_command
253
+ # to create CheckoutCommand objects.
254
+ def initialize(frontend)
255
+ super(frontend)
256
+ @shopping_cart = ShoppingCart.new(self)
257
+ @tax_tables = frontend.tax_table_factory.effective_tax_tables_at(Time.new)
258
+ @shipping_methods = Array.new
259
+ end
260
+
261
+ # Use this method to create a new shipping method. You have to pass in one of
262
+ # { PickupShipping, FlatRateShipping } for clazz. The method will create a
263
+ # new instance of the class you passedin object and add it to the internal list
264
+ # of shipping methods.
265
+ #
266
+ # If you pass a block to this method (preferred) then the newly created
267
+ # ShippingMethod object will be passed into this block for setting its attributes.
268
+ # The newly created shipping method will be returned in all cases.
269
+ #
270
+ # The first created shipping method will be used as the default.
271
+ #
272
+ # Raises a ArgumentError if the parameter clazz is invalid.
273
+ def create_shipping_method(clazz, &block)
274
+ if not [ PickupShipping, FlatRateShipping,
275
+ MerchantCalculatedShipping, CarrierCalculatedShipping
276
+ ].include?(clazz) then
277
+ raise ArgumentError, "Unknown shipping method: #{clazz.inspect}."
278
+ end
279
+
280
+ shipping_method = clazz.new
281
+ @shipping_methods << shipping_method
282
+
283
+ yield(shipping_method) if block_given?
284
+
285
+ return shipping_method
286
+ end
287
+ end
288
+
289
+ # CheckoutRedirectResponse instances are returned when a CheckoutCommand is successfully
290
+ # processed by Google Checkout.
291
+ class CheckoutRedirectResponse
292
+ # The serial number of the <checkout-redirect> response.
293
+ attr_reader :serial_number
294
+
295
+ # The URL to redirect to.
296
+ attr_reader :redirect_url
297
+
298
+ # Create a new CheckoutRedirectResponse with the given serial number and redirection URL.
299
+ # Do not create CheckoutRedirectResponse instances in your own code. Google4R creates them
300
+ # for you.
301
+ def initialize(serial_number, redirect_url)
302
+ @serial_number = serial_number
303
+ @redirect_url = redirect_url
304
+ end
305
+
306
+ def to_s
307
+ return @redirect_url
308
+ end
309
+ end
310
+
311
+ #
312
+ # The ChargeOrderCommand instructs Google Checkout to charge the buyer for a
313
+ # particular order.
314
+ #
315
+ class ChargeOrderCommand < Command
316
+ # The amount to charge, optional, Money
317
+ attr_accessor :amount
318
+
319
+ # Generates the XML for this ChargeOrderCommand
320
+ def to_xml
321
+ ChargeOrderCommandXmlGenerator.new(self).generate
322
+ end
323
+ end
324
+
325
+ # The RefundOrderCommand instructs Google Checkout to refund an order
326
+ class RefundOrderCommand < Command
327
+ # The amount to refund, optional, Money
328
+ attr_accessor :amount
329
+
330
+ # The reason that the order is to be refunded, String of maximum 140 characters, required
331
+ attr_accessor :reason
332
+
333
+ # A comment related to the refunded order, String of maximum 140 characters, optional
334
+ attr_accessor :comment
335
+
336
+ def to_xml
337
+ RefundOrderCommandXmlGenerator.new(self).generate
338
+ end
339
+ end
340
+
341
+ # The CancelOrderCommand instructs Google Checkout to cancel an order
342
+ class CancelOrderCommand < Command
343
+ # The reason that the order is to be cancelled, String of maximum 140 characters, required
344
+ attr_accessor :reason
345
+
346
+ # A comment related to the cancelled order, String of maximum 140 characters, optional
347
+ attr_accessor :comment
348
+
349
+ def to_xml
350
+ CancelOrderCommandXmlGenerator.new(self).generate
351
+ end
352
+ end
353
+
354
+ # The AuthorizeOrderCommand instructs Google Checkout to explicitly reauthorize
355
+ # a customer's credit card for the uncharged balance of an order to verify that
356
+ # funds for the order are available
357
+ class AuthorizeOrderCommand < Command
358
+ def to_xml
359
+ AuthorizeOrderCommandXmlGenerator.new(self).generate
360
+ end
361
+ end
362
+
363
+ # The ProcessOrderCommand instructs Google Checkout to to update
364
+ # an order's fulfillment state from NEW to PROCESSING
365
+ class ProcessOrderCommand < Command
366
+ def to_xml
367
+ ProcessOrderCommandXmlGenerator.new(self).generate
368
+ end
369
+ end
370
+
371
+ # The AddMerchantOrderCommand instructs Google Checkout to associate a
372
+ # merchant-assigned order number with an order
373
+ class AddMerchantOrderNumberCommand < Command
374
+ # The merchant-assigned order number associated with an order
375
+ attr_accessor :merchant_order_number
376
+
377
+ def to_xml
378
+ AddMerchantOrderNumberCommandXmlGenerator.new(self).generate
379
+ end
380
+ end
381
+
382
+ # The DeliverOrderCommand indicates that Google should update an order's fulfillment order state to DELIVERED
383
+ class DeliverOrderCommand < Command
384
+ # if google checkout should email buyer to ssay order is dispatched
385
+ attr_accessor :send_email
386
+
387
+ # The name of the company responsible for shipping the item. Valid values
388
+ # for this tag are DHL, FedEx, UPS, USPS and Other.
389
+ attr_accessor :carrier
390
+
391
+ # The shipper's tracking number that is associated with an order
392
+ attr_accessor :tracking_number
393
+
394
+ def to_xml
395
+ DeliverOrderCommandXmlGenerator.new(self).generate
396
+ end
397
+ end
398
+
399
+ # The AddTrackingDataCommand instructs Google Checkout to associate a shipper's tracking number with an order.
400
+ class AddTrackingDataCommand < Command
401
+ # The name of the company responsible for shipping the item. Valid values
402
+ # for this tag are DHL, FedEx, UPS, USPS and Other.
403
+ attr_accessor :carrier
404
+
405
+ # The shipper's tracking number that is associated with an order
406
+ attr_accessor :tracking_number
407
+
408
+ def to_xml
409
+ AddTrackingDataCommandXmlGenerator.new(self).generate
410
+ end
411
+ end
412
+
413
+ # The SendBuyerMessageCommand instructs Google Checkout to place a message in the customer's Google Checkout account.
414
+ class SendBuyerMessageCommand < Command
415
+ # The message to the customer
416
+ attr_accessor :message
417
+
418
+ # if google checkout should email buyer to say order is dispatched
419
+ attr_accessor :send_email
420
+
421
+ def to_xml
422
+ SendBuyerMessageCommandXmlGenerator.new(self).generate
423
+ end
424
+ end
425
+
426
+ # The ArchiveOrderCommand instructs Google Checkout to remove an order from your Merchant Center Inbox.
427
+ class ArchiveOrderCommand < Command
428
+ def to_xml
429
+ ArchiveOrderCommandXmlGenerator.new(self).generate
430
+ end
431
+ end
432
+
433
+ # The UnarchiveOrderCommand instructs Google Checkout to return a previously archived order to your Merchant Center Inbox.
434
+ class UnarchiveOrderCommand < Command
435
+ def to_xml
436
+ UnarchiveOrderCommandXmlGenerator.new(self).generate
437
+ end
438
+ end
439
+
440
+ #
441
+ # XML API Commands for Line-item Shipping
442
+ #
443
+
444
+ # Abstract class for Line-item shipping commands
445
+ class ItemsCommand < Command
446
+ # An array of ItemInfo objects that you are marking as backordered,
447
+ # cancelled, returned or resetting shipping information
448
+ attr_accessor :item_info_arr
449
+
450
+ # if google checkout should email buyer to say order is dispatched
451
+ attr_accessor :send_email
452
+
453
+ def initialize(frontend)
454
+ super
455
+ @item_info_arr = []
456
+ @send_email = false
457
+ end
458
+ end
459
+
460
+ # The <ship-items> command specifies shipping information for one or
461
+ # more items in an order.
462
+ class ShipItemsCommand < ItemsCommand
463
+ def to_xml
464
+ ShipItemsCommandXmlGenerator.new(self).generate
465
+ end
466
+ end
467
+
468
+ # The <backorder-items> command lets you specify that one or more
469
+ # specific items in an order are out of stock.
470
+ class BackorderItemsCommand < ItemsCommand
471
+ def to_xml
472
+ BackorderItemsCommandXmlGenerator.new(self).generate
473
+ end
474
+ end
475
+
476
+ # The <cancel-items> command lets you specify that one or more
477
+ # specific items in an order have been cancelled, meaning they
478
+ # will not be delivered to the customer.
479
+ class CancelItemsCommand < ItemsCommand
480
+ # The reason that you are canceling one or more line items
481
+ attr_accessor :reason
482
+
483
+ # An optional comment related to one or more canceled line items
484
+ attr_accessor :comment
485
+
486
+ def to_xml
487
+ CancelItemsCommandXmlGenerator.new(self).generate
488
+ end
489
+ end
490
+
491
+ # The <return-items> command lets you specify that your customer
492
+ # returned one or more specific items in an order.
493
+ class ReturnItemsCommand < ItemsCommand
494
+ def to_xml
495
+ ReturnItemsCommandXmlGenerator.new(self).generate
496
+ end
497
+ end
498
+
499
+ # The <reset-items-shipping-information> command allows you to reset
500
+ # the shipping status for specific items in an order to "Not yet shipped".
501
+ class ResetItemsShippingInformationCommand < ItemsCommand
502
+ def to_xml
503
+ ResetItemsShippingInformationCommandXmlGenerator.new(self).generate
504
+ end
505
+ end
506
+
507
+ # The <order-list-request> command lets you to download a list of
508
+ # Google Checkout orders into a comma-separated file.
509
+ # The API will return a list of orders for a period of up to 31 days,
510
+ # and you can limit results to orders that have specific financial or
511
+ # fulfillment order states.
512
+ # http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API_Order_Report_API.html
513
+ class OrderReportCommand < Command
514
+ # The earliest time that an order could have been submitted to be
515
+ # included in the API response (Time)
516
+ attr_reader :start_date
517
+
518
+ # The time before which an order must have been sent to be included
519
+ # in the API response (Time)
520
+ attr_reader :end_date
521
+
522
+ # The financial status of an order
523
+ attr_accessor :financial_state
524
+
525
+ # The fulfillment status of an order
526
+ attr_accessor :fulfillment_state
527
+
528
+ # The time zone that will be associated with the start date and
529
+ # end date for the report
530
+ attr_accessor :date_time_zone
531
+
532
+ def initialize(frontend, start_date, end_date)
533
+ super frontend
534
+ raise 'start_date has to be of type Time' unless start_date.class == Time
535
+ raise 'end_date has to be of type Time' unless start_date.class == Time
536
+ raise 'end_date has to be before start_date' unless
537
+ end_date >= start_date
538
+ @start_date = start_date
539
+ @end_date = end_date
540
+ end
541
+
542
+ def start_date
543
+ return @start_date.strftime('%Y-%m-%dT%H:%M:%S')
544
+ end
545
+
546
+ def end_date
547
+ return @end_date.strftime('%Y-%m-%dT%H:%M:%S')
548
+ end
549
+
550
+ def financial_state=(financial_state)
551
+ raise 'Invalid financial state %s' % financial_state unless
552
+ FinancialState.constants.include?(financial_state)
553
+ @financial_state = financial_state
554
+ end
555
+
556
+ def fulfillment_state=(fulfillment_state)
557
+ raise 'Invalid fulfillment state %s' % fulfillment_state unless
558
+ FulfillmentState.constants.include?(fulfillment_state)
559
+ @fulfillment_state = fulfillment_state
560
+ end
561
+
562
+ def to_xml
563
+ ReturnOrderReportCommandXmlGenerator.new(self).generate
564
+ end
565
+ end
566
+ end
567
+ end