golf_switch 1.0.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.
Files changed (50) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +6 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +127 -0
  5. data/Rakefile +1 -0
  6. data/examples/area_test.rb +15 -0
  7. data/examples/book_golf.rb +74 -0
  8. data/examples/cancel_booking.rb +78 -0
  9. data/examples/course_avail.rb +26 -0
  10. data/examples/course_avail_list.rb +33 -0
  11. data/examples/course_info.rb +15 -0
  12. data/examples/course_list.rb +15 -0
  13. data/examples/course_policy_test.rb +15 -0
  14. data/golf_switch.gemspec +20 -0
  15. data/lib/golf_switch.rb +42 -0
  16. data/lib/golf_switch/alt_rate_type.rb +28 -0
  17. data/lib/golf_switch/area.rb +52 -0
  18. data/lib/golf_switch/area_response.rb +27 -0
  19. data/lib/golf_switch/available_course.rb +53 -0
  20. data/lib/golf_switch/book_golf.rb +41 -0
  21. data/lib/golf_switch/book_golf_item.rb +50 -0
  22. data/lib/golf_switch/cancel_golf.rb +49 -0
  23. data/lib/golf_switch/cancel_golf_response.rb +16 -0
  24. data/lib/golf_switch/configuration.rb +28 -0
  25. data/lib/golf_switch/country.rb +30 -0
  26. data/lib/golf_switch/country_region.rb +29 -0
  27. data/lib/golf_switch/course.rb +28 -0
  28. data/lib/golf_switch/course_avail.rb +73 -0
  29. data/lib/golf_switch/course_avail_date.rb +25 -0
  30. data/lib/golf_switch/course_avail_list.rb +85 -0
  31. data/lib/golf_switch/course_avail_request.rb +56 -0
  32. data/lib/golf_switch/course_avail_time.rb +31 -0
  33. data/lib/golf_switch/course_info.rb +38 -0
  34. data/lib/golf_switch/course_info_course.rb +90 -0
  35. data/lib/golf_switch/course_list.rb +62 -0
  36. data/lib/golf_switch/course_list_course.rb +27 -0
  37. data/lib/golf_switch/course_policy.rb +14 -0
  38. data/lib/golf_switch/course_policy_response.rb +18 -0
  39. data/lib/golf_switch/get_alt_rate_type.rb +42 -0
  40. data/lib/golf_switch/get_course_policy.rb +50 -0
  41. data/lib/golf_switch/get_golf_booking.rb +49 -0
  42. data/lib/golf_switch/golf_book.rb +42 -0
  43. data/lib/golf_switch/golf_book_info.rb +17 -0
  44. data/lib/golf_switch/payment.rb +39 -0
  45. data/lib/golf_switch/player.rb +35 -0
  46. data/lib/golf_switch/region_area.rb +13 -0
  47. data/lib/golf_switch/request.rb +62 -0
  48. data/lib/golf_switch/score_card.rb +5 -0
  49. data/lib/golf_switch/version.rb +3 -0
  50. metadata +110 -0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_STORE
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in golf_switch.gemspec
4
+ gemspec
5
+ gem 'savon'
6
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 amardaxini
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,127 @@
1
+ # GolfSwitch
2
+
3
+ Ruby Wrapper of golf switch api
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'golf_switch'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install golf_switch
18
+
19
+ ## Usage
20
+
21
+ ### Configure Golf Switch
22
+
23
+ GolfSwitch.configure do |config|
24
+ config.reseller_id="GHE"
25
+ config.partner_id=""
26
+ config.source_cd="A"
27
+ config.lang=""
28
+ config.user_ip="120.62.168.214"
29
+ config.user_session_id=""
30
+ config.access_key=""
31
+ config.gs_source=""
32
+ end
33
+
34
+
35
+
36
+ ### [Area API](https://devxml.golfswitch.com/examples/definitions.htm#areas)
37
+ # parameter country_id,region_id (optional)
38
+
39
+ area = GolfSwitch::Area.new({:country_id=>"USA"})
40
+ area.commit # Fire API request
41
+ area.response # API RAW Response
42
+ area.error? # API Error?
43
+ area.error_message # API Error message
44
+
45
+ # return [] or Array of counties with name and it's id
46
+ # each country has array of regions with name and it's id
47
+ # each region has array of areas with name and it's id
48
+ # Country: [Country(area_id,name,country_regions=[Regions])
49
+ # Region:[CountryRegion(area_id,name,region_areas=[Area])
50
+ # Area: [RegionArea(area_id,name)
51
+
52
+ area.parse_response #store result in area.api_response
53
+
54
+ # get all countries
55
+ area.api_response
56
+
57
+ # Country region
58
+ country.regions
59
+
60
+ # Region Area
61
+ region.areas
62
+
63
+ ### [Course List API](https://devxml.golfswitch.com/examples/definitions.htm#courselist)
64
+ # option attributes
65
+ # country_id,region_id,area,latitude,longitude,postal_code,
66
+ # max_distance,max_distance_type,show_all_status,show_dis_connected
67
+ # featured_only,:sort
68
+
69
+ option_attributes = {:country_id=>"USA"}
70
+ course_list = GolfSwitch::CourseList.new(option_attributes)
71
+ course_list.commit # Fire APi Request
72
+ course_list.response # API RAW Response
73
+ course_list.error_message # API Error message
74
+
75
+ # return [] or Array of courses with course info
76
+ course_list.parse_response
77
+
78
+ course_list.api_response # parsed response
79
+
80
+
81
+ ### [Course Avail List API](https://devxml.golfswitch.com/examples/definitions.htm#courseavaillist)
82
+ # option attributes
83
+ # country_id,region_id,area,play_beg_date,play_end_date,
84
+ # time,players,alt_rate_type,promo_code,latitude,
85
+ #longitude,postal_code,max_distance,max_distance_type,
86
+ # show_all_times,show_if_no_times....
87
+
88
+ option_attributes = {:country_id=>"USA"}
89
+ course_list = GolfSwitch::CourseAvailList.new(option_attributes)
90
+ course_list.commit # Fire APi Request
91
+ course_list.response # API RAW Response
92
+ course_list.error_message # API Error message
93
+
94
+ # return [] or Array of courses with course info
95
+ # and dates and time with payment details
96
+
97
+ course_list.parse_response
98
+ course_list.api_response # parsed response
99
+
100
+ ### [Course Info API](https://devxml.golfswitch.com/examples/definitions.htm#courseinfo)
101
+ course_id = "14002"
102
+ course = GolfSwitch::CourseInfo.new(course_id)
103
+ course.commit # Fire APi Request
104
+ course.response # API RAW Response
105
+ course.error_message # API Error message
106
+
107
+ # return course info with hole,images,score card and other detail
108
+
109
+ course_list.parse_response
110
+ course_list.api_response # parsed response
111
+
112
+
113
+
114
+ ### Reference
115
+
116
+ [Golf Switch API Reference ](https://devxml.golfswitch.com/golfservice.asmx)
117
+
118
+ [WSDL](https://devxml.golfswitch.com/golfservice.asmx?WSDL)
119
+
120
+ [Example Defination](https://devxml.golfswitch.com/examples/definitions.htm)
121
+ ## Contributing
122
+
123
+ 1. Fork it
124
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
125
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
126
+ 4. Push to the branch (`git push origin my-new-feature`)
127
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ require_relative "./../lib/golf_switch"
2
+ GolfSwitch.configure do |config|
3
+ config.reseller_id="GHE"
4
+ config.partner_id=""
5
+ config.source_cd="A"
6
+ config.lang=""
7
+ config.user_ip="120.62.161.103"
8
+ config.user_session_id="some_session"
9
+ config.access_key="some_access_key"
10
+ config.gs_source=""
11
+ end
12
+ area1 = GolfSwitch::Area.new({:country_id=>"USA",:region_id=>"IL"})
13
+ area1.commit
14
+ area1.parse_response
15
+ area1.api_response
@@ -0,0 +1,74 @@
1
+ require_relative "./../lib/golf_switch"
2
+ GolfSwitch.configure do |config|
3
+ config.reseller_id="GHE"
4
+ config.partner_id=""
5
+ config.source_cd="A"
6
+ config.lang=""
7
+ config.user_ip="120.62.161.103"
8
+ config.user_session_id="some_session"
9
+ config.access_key="some_access_key"
10
+ config.gs_source=""
11
+ end
12
+
13
+ player_attributes= {
14
+ :first_name=>"Amar",
15
+ :last_name=>"Daxini",
16
+ :email=>"amardaxini@gmail.com",
17
+ :phone=>"0000000000",
18
+ :city=>"New York",
19
+ :state=>"NY",
20
+ :country=>"US",
21
+ :postal_code=>"10015"
22
+ }
23
+ player1 = GolfSwitch::Player.new(player_attributes)
24
+ # player2 = GolfSwitch::Player.new(player_attributes)
25
+ # player3 = GolfSwitch::Player.new(player_attributes)
26
+ # player4 = GolfSwitch::Player.new(player_attributes)
27
+ payment_attributes = {
28
+ :pay_type=>"CC",
29
+ :cc_type=>"VI",
30
+ :pay_number=>"4321432143214327",
31
+ :cc_exp_mo=>"11",
32
+ :cc_exp_yr=>"2014",
33
+ :cc_name=>"Amar Daxini",
34
+ :cc_address1=>"153 State Park Rd",
35
+ :cc_city=>"New York",
36
+ :cc_state=>"NY",
37
+ :cc_country=>"US",
38
+ :cc_postal_code=>"10015",
39
+ :pay_amount=>"400.00",
40
+ :pay_curr=>"USD"
41
+ }
42
+ payment = GolfSwitch::Payment.new(payment_attributes)
43
+
44
+ book_golf_item_attributes= {
45
+ :course_id=>"14002",
46
+ :play_date=>"2013-04-05",
47
+ :play_time=>"0725",
48
+ :num_players=>"4",
49
+ :pp_price=>"100.00",
50
+ :curr=>"USD",
51
+ :pp_charge=>"100.00",
52
+ :pp_txn_fee=>"2.00",
53
+ :chrg_curr=>"USD",
54
+ :pp_non_ref=>"2.00",
55
+ :pp_net_rt=>"80.0000",
56
+ :tot_price=>"400.00",
57
+ :tot_txn_fee=>"8.00",
58
+ :tot_charge=>"400.00",
59
+ :tot_non_ref=>"8.00",
60
+ :tot_net_rt=>"320.00",
61
+ :flags=>nil,
62
+ :players=>[player1],
63
+ :payment=>payment,
64
+ :ignore_pricing=>true
65
+ }
66
+
67
+ book_golf_item = GolfSwitch::BookGolfItem.new(book_golf_item_attributes)
68
+
69
+ book_golf = GolfSwitch::BookGolf.new()
70
+ book_golf.book_golf_items << book_golf_item
71
+ #
72
+ book_golf.commit
73
+ book_golf.parse_response
74
+ book_golf.api_response
@@ -0,0 +1,78 @@
1
+ require_relative "./../lib/golf_switch"
2
+ GolfSwitch.configure do |config|
3
+ config.reseller_id="GHE"
4
+ config.partner_id=""
5
+ config.source_cd="A"
6
+ config.lang=""
7
+ config.user_ip="120.62.161.103"
8
+ config.user_session_id="some_session"
9
+ config.access_key="some_access_key"
10
+ config.gs_source=""
11
+ end
12
+
13
+ player_attributes= {
14
+ :first_name=>"Amar",
15
+ :last_name=>"Daxini",
16
+ :email=>"amardaxini@gmail.com",
17
+ :phone=>"0000000000",
18
+ :city=>"New York",
19
+ :state=>"NY",
20
+ :country=>"US",
21
+ :postal_code=>"10015"
22
+ }
23
+ player1 = GolfSwitch::Player.new(player_attributes)
24
+ # player2 = GolfSwitch::Player.new(player_attributes)
25
+ # player3 = GolfSwitch::Player.new(player_attributes)
26
+ # player4 = GolfSwitch::Player.new(player_attributes)
27
+ payment_attributes = {
28
+ :pay_type=>"CC",
29
+ :cc_type=>"VI",
30
+ :pay_number=>"4321432143214327",
31
+ :cc_exp_mo=>"11",
32
+ :cc_exp_yr=>"2014",
33
+ :cc_name=>"Amar Daxini",
34
+ :cc_address1=>"153 State Park Rd",
35
+ :cc_city=>"New York",
36
+ :cc_state=>"NY",
37
+ :cc_country=>"US",
38
+ :cc_postal_code=>"10015",
39
+ :pay_amount=>"400.00",
40
+ :pay_curr=>"USD"
41
+ }
42
+ payment = GolfSwitch::Payment.new(payment_attributes)
43
+
44
+ book_golf_item_attributes= {
45
+ :course_id=>"14002",
46
+ :play_date=>"2013-04-20",
47
+ :play_time=>"0725",
48
+ :num_players=>"4",
49
+ :pp_price=>"100.00",
50
+ :curr=>"USD",
51
+ :pp_charge=>"100.00",
52
+ :pp_txn_fee=>"2.00",
53
+ :chrg_curr=>"USD",
54
+ :pp_non_ref=>"2.00",
55
+ :pp_net_rt=>"80.0000",
56
+ :tot_price=>"400.00",
57
+ :tot_txn_fee=>"8.00",
58
+ :tot_charge=>"400.00",
59
+ :tot_non_ref=>"8.00",
60
+ :tot_net_rt=>"320.00",
61
+ :flags=>nil,
62
+ :players=>[player1],
63
+ :payment=>payment,
64
+ :ignore_pricing=>true
65
+ }
66
+
67
+ book_golf_item = GolfSwitch::BookGolfItem.new(book_golf_item_attributes)
68
+
69
+ book_golf = GolfSwitch::BookGolf.new()
70
+ book_golf.book_golf_items << book_golf_item
71
+ #
72
+ book_golf.commit
73
+
74
+ book_golf.parse_response
75
+ res = book_golf.api_response[0]
76
+ cancel_book = GolfSwitch::CancelGolf.new("14002","2013-04-20",res.confirmation_no,res.booking_id)
77
+ cancel_book.commit
78
+ cancel_book.parse_response
@@ -0,0 +1,26 @@
1
+ require_relative "./../lib/golf_switch"
2
+ GolfSwitch.configure do |config|
3
+ config.reseller_id="GHE"
4
+ config.partner_id=""
5
+ config.source_cd="A"
6
+ config.lang=""
7
+ config.user_ip="120.62.161.103"
8
+ config.user_session_id="some_session"
9
+ config.access_key="some_access_key"
10
+ config.gs_source=""
11
+ end
12
+ time = DateTime.now
13
+ date = Date.new(time.year, time.mon, time.day+1).strftime("%Y-%m-%d")
14
+ avail_list = GolfSwitch::CourseAvail.new({:course_id=>"14003",:play_beg_date=>date,:play_end_date=>date})
15
+ avail_list.commit
16
+ avail_list.parse_response
17
+ avail_list
18
+ # avail_lists = GolfSwitch::CourseAvailRequest.new()
19
+ # avail_list1 = GolfSwitch::CourseAvail.new({:course_id=>"14003",:play_beg_date=>Date.today.strftime("%Y-%m-%d"),:play_end_date=>Date.today.strftime("%Y-%m-%d")})
20
+ # avail_lists.course_avails << avail_list
21
+ # avail_lists.course_avails << avail_list1
22
+
23
+ # avail_lists.commit
24
+ # avail_lists.parse_response
25
+ # binding.pry
26
+ # avail_lists
@@ -0,0 +1,33 @@
1
+ require_relative "./../lib/golf_switch"
2
+ GolfSwitch.configure do |config|
3
+ config.reseller_id="GHE"
4
+ config.partner_id=""
5
+ config.source_cd="A"
6
+ config.lang=""
7
+ config.user_ip="120.62.161.103"
8
+ config.user_session_id="some_session"
9
+ config.access_key="some_access_key"
10
+ config.gs_source=""
11
+
12
+ end
13
+ # GolfSwitch.configuration.golf_switch_wsdl = "https://xml.golfswitch.com/golfService.asmx?WSDL"
14
+
15
+ avail_list = GolfSwitch::CourseAvailList.new({:country_id=>"USA",:region_id=>"CO",:play_beg_date=>Date.today.strftime("%Y-%m-%d"),:play_end_date=>Date.today.strftime("%Y-%m-%d"),:time=>"1009",:barter_only=>true})
16
+ avail_list.commit
17
+ avail_list.parse_response
18
+ avail_list.api_response
19
+ avail_list1 = GolfSwitch::CourseAvailList.new({:country_id=>"USA",:region_id=>"CA",:play_beg_date=>Date.today.strftime("%Y-%m-%d"),:play_end_date=>Date.today.strftime("%Y-%m-%d"),:show_all_times=>true,:time=>"1009"})
20
+ avail_list1.commit
21
+ avail_list1.parse_response
22
+ avail_list1.api_response
23
+
24
+ avail_list2 = GolfSwitch::CourseAvailList.new({:country_id=>"USA",:region_id=>"CA",:play_beg_date=>Date.today.strftime("%Y-%m-%d"),:play_end_date=>Date.today.strftime("%Y-%m-%d"),:show_all_times=>true,:time=>"1009",:latitude=>"36.778261",:longitude=>"-119.4179324",:max_distance=>1000})
25
+ avail_list2.commit
26
+ avail_list2.parse_response
27
+ avail_list2.api_response
28
+
29
+
30
+ hot_deals = GolfSwitch::CourseAvailList.new({:country_id=>"USA",:region_id=>"CA",:play_beg_date=>Date.today.strftime("%Y-%m-%d"),:play_end_date=>Date.today.strftime("%Y-%m-%d"),:show_all_times=>true,:time=>"1009",:barter_only=>true})
31
+ hot_deals.commit
32
+ hot_deals.parse_response
33
+ hot_deals.api_response
@@ -0,0 +1,15 @@
1
+ require_relative "./../lib/golf_switch"
2
+ GolfSwitch.configure do |config|
3
+ config.reseller_id="GHE"
4
+ config.partner_id=""
5
+ config.source_cd="A"
6
+ config.lang=""
7
+ config.user_ip="120.62.161.103"
8
+ config.user_session_id="some_session"
9
+ config.access_key="some_access_key"
10
+ config.gs_source=""
11
+ end
12
+ course_info = GolfSwitch::CourseInfo.new("18633")
13
+ course_info.commit
14
+ course_info.parse_response
15
+ course_info.api_response
@@ -0,0 +1,15 @@
1
+ require_relative "./../lib/golf_switch"
2
+ GolfSwitch.configure do |config|
3
+ config.reseller_id="GHE"
4
+ config.partner_id=""
5
+ config.source_cd="A"
6
+ config.lang=""
7
+ config.user_ip="120.62.167.249"
8
+ config.user_session_id="some_session"
9
+ config.access_key="some_access_key"
10
+ config.gs_source=""
11
+ end
12
+ course_list = GolfSwitch::CourseList.new({:country_id=>"USA",:region_id=>"WI",:area=>"Northern Wisconsin"})
13
+ course_list.commit
14
+ course_list.parse_response
15
+ course_list.api_response