goldshark_gem 0.1.1 → 0.1.2

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.
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://gst.api.igodigital.com/v2_2/7c7a63f6-8bcb-4fee-bc9d-8a2f5e477887/text.json?locale=en
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Content-Type:
20
+ - application/json;charset=utf-8
21
+ Date:
22
+ - Fri, 19 Oct 2012 02:00:41 GMT
23
+ Server:
24
+ - Apache/2.2.16 (Amazon)
25
+ Status:
26
+ - '200'
27
+ X-Frame-Options:
28
+ - sameorigin
29
+ X-Powered-By:
30
+ - Phusion Passenger (mod_rails/mod_rack) 3.0.9
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ Content-Length:
34
+ - '3289'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: US-ASCII
39
+ string: ! '[{"locale":"en","text_title":"","text_value":"Search by model number","text_type":"search_label"},{"locale":"en","text_title":"","text_value":"Find
40
+ shaving heads that match your shaver","text_type":"welcome_header"},{"locale":"en","text_title":"","text_value":"Or
41
+ take the step by step guide","text_type":"start_header"},{"locale":"en","text_title":"","text_value":"Start
42
+ the guide","text_type":"start_button_text"},{"locale":"en","text_title":"","text_value":"Search","text_type":"search_button_text"},{"locale":"en","text_title":"","text_value":"Find
43
+ shaving heads that match your shaver","text_type":"header_text"},{"locale":"en","text_title":"","text_value":"Start
44
+ new search","text_type":"restart_text"},{"locale":"en","text_title":"","text_value":"Next
45
+ question","text_type":"next_button_text"},{"locale":"en","text_title":"","text_value":"Previous
46
+ question","text_type":"previous_button_text"},{"locale":"en","text_title":"","text_value":"Where
47
+ to find this icon on my shaver?","text_type":"where_to_find_text"},{"locale":"en","text_title":"","text_value":"Recommendation","text_type":"recommendation_text"},{"locale":"en","text_title":"","text_value":"Matching
48
+ shavers","text_type":"match_heading"},{"locale":"en","text_title":"Buy Now","text_value":"Buy
49
+ Now","text_type":"buy_now_text"},{"locale":"en","text_title":"","text_value":"View
50
+ product details ","text_type":"view_details_text"},{"locale":"en","text_title":"","text_value":"Download
51
+ leaflet","text_type":"view_leaflet_text"},{"locale":"en","text_title":"","text_value":"Print
52
+ advice","text_type":"print_text"},{"locale":"en","text_title":"","text_value":"Register
53
+ to receive a reminder","text_type":"replacement_advice"},{"locale":"en","text_title":"","text_value":"Receive
54
+ reminder","text_type":"reminder_text"},{"locale":"en","text_title":"","text_value":"Recommended
55
+ shaver head","text_type":"recommended_shaver_text"},{"locale":"en","text_title":"","text_value":"How
56
+ to replace your shaver head","text_type":"how_to_replace_text"},{"locale":"en","text_title":"","text_value":"shaving
57
+ heads","text_type":"shaving_heads"},{"locale":"en","text_title":"","text_value":"Where
58
+ can I find my model number?","text_type":"where_to_find_model_text"},{"locale":"en","text_title":"","text_value":"Sorry,
59
+ we found no results for","text_type":"keyword_results_error"},{"locale":"en","text_title":"","text_value":"If
60
+ you want to try again please check your model number","text_type":"try_search_again_text"},{"locale":"en","text_title":"","text_value":"results
61
+ for","text_type":"keyword_results"},{"locale":"en","text_title":"","text_value":"Please
62
+ check your model number or","text_type":"check_model_text"},{"locale":"en","text_title":"","text_value":"results","text_type":"results_text"},{"locale":"en","text_title":"","text_value":"series","text_type":"series_text"},{"locale":"en","text_title":"","text_value":"We
63
+ cannot offer a package with 2 heads. This package is compatible.","text_type":"no_compatible_text"},{"locale":"en","text_title":"","text_value":"results
64
+ so far","text_type":"search_results_text"},{"locale":"en","text_title":"","text_value":"Showing","text_type":"showing_text"},{"locale":"en","text_title":"","text_value":"https://pnregistration.harte-hanks.com/Registration.aspx","text_type":"registration_url"}]'
65
+ http_version:
66
+ recorded_at: Fri, 19 Oct 2012 02:00:41 GMT
67
+ recorded_with: VCR 2.2.5
@@ -7,33 +7,33 @@ http_interactions:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
- accept:
10
+ Accept:
11
11
  - ! '*/*'
12
- user-agent:
12
+ User-Agent:
13
13
  - Ruby
14
14
  response:
15
15
  status:
16
16
  code: 200
17
17
  message: OK
18
18
  headers:
19
- content-type:
19
+ Content-Type:
20
20
  - application/json;charset=utf-8
21
- date:
22
- - Fri, 14 Sep 2012 15:30:07 GMT
23
- server:
21
+ Date:
22
+ - Fri, 19 Oct 2012 01:58:49 GMT
23
+ Server:
24
24
  - Apache/2.2.16 (Amazon)
25
- status:
25
+ Status:
26
26
  - '200'
27
- x-frame-options:
27
+ X-Frame-Options:
28
28
  - sameorigin
29
- x-powered-by:
30
- - Phusion Passenger (mod_rails/mod_rack) 3.0.9
31
- x-xss-protection:
29
+ X-Powered-By:
30
+ - Phusion Passenger (mod_rails/mod_rack) 3.0.11
31
+ X-Xss-Protection:
32
32
  - 1; mode=block
33
- content-length:
33
+ Content-Length:
34
34
  - '4495'
35
- connection:
36
- - Close
35
+ Connection:
36
+ - keep-alive
37
37
  body:
38
38
  encoding: US-ASCII
39
39
  string: ! '{"tool_name":"This tool is used for monitoring only --- Philips -
@@ -63,6 +63,6 @@ http_interactions:
63
63
  the back side is green","step_option_notes":"","tool_step_option_id":"419ff79f-14a9-4702-bb05-269b7461e2b4","image_type":"jpg"},{"parent_step_option_name":"Yes,
64
64
  the shaving head is on a ''neck''","parent_tool_step_option_id":"0031fade-61db-458d-a189-cad2db67427e","sort_order":1,"step_option_desc":"HQ56/52
65
65
  ","step_option_name":"No, the back side is not green","step_option_notes":"no-image","tool_step_option_id":"29bf4cd7-1504-443f-8541-fee1fe73c921","image_type":"jpg"}]}]}'
66
- http_version: '1.1'
67
- recorded_at: Fri, 14 Sep 2012 15:30:06 GMT
66
+ http_version:
67
+ recorded_at: Fri, 19 Oct 2012 01:58:49 GMT
68
68
  recorded_with: VCR 2.2.5
data/test/helper.rb CHANGED
@@ -4,6 +4,7 @@ Bundler.require(:default, :test)
4
4
  require 'goldshark_gem'
5
5
  require 'minitest/unit'
6
6
  require 'turn'
7
+ require 'webmock'
7
8
 
8
9
  class MiniTest::Unit::TestCase
9
10
  def self.test(name, &block)
data/test/text_test.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+ require 'minitest/autorun'
3
+
4
+ class TestText < MiniTest::Unit::TestCase
5
+
6
+ def setup
7
+ @gstxt = GS::Text.new
8
+ @gstxt.tool_guid("7c7a63f6-8bcb-4fee-bc9d-8a2f5e477887")
9
+ @gstxt.locale("en")
10
+ end
11
+
12
+ def test_that_can_find_text
13
+ VCR.use_cassette('test_text') do
14
+ @gstxt.load_text
15
+ assert_equal @gstxt.find('showing_text'), 'Showing'
16
+ end
17
+ end
18
+ end
data/test/tool_test.rb ADDED
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+ require 'minitest/autorun'
3
+
4
+ class TestTool < MiniTest::Unit::TestCase
5
+
6
+ def setup
7
+ @gs = GS::Tool.new
8
+ @gs.tool_guid('7c7a63f6-8bcb-4fee-bc9d-8a2f5e477887')
9
+ @gs.locale('en')
10
+ @gs.session_id('7c7a63f6-8bcb-4fee-bc9d-8a2f5e477887')
11
+ @tool_step_option_ids = ['0e1ba264-7ed2-4a85-b9cb-75aa50b2b43c', '1c3d1d63-556d-482d-aaf0-8b3700deb29b', '0031fade-61db-458d-a189-cad2db67427e', '419ff79f-14a9-4702-bb05-269b7461e2b4']
12
+ end
13
+
14
+ def test_that_can_get_right_session
15
+ VCR.use_cassette('test_tool') do
16
+ @tool = @gs.get_tool
17
+ assert_equal '7c7a63f6-8bcb-4fee-bc9d-8a2f5e477887', @tool[:session_id]
18
+ end
19
+ end
20
+
21
+ def test_that_can_update_tool_options
22
+ VCR.use_cassette('test_tool') do
23
+ @tool = @gs.get_tool
24
+ @tool[:steps] = @gs.update_tool_options(@tool, @tool_step_option_ids)
25
+ options = @tool[:steps].map{|step| step[:selected_options]}.reject{|o| o === ''}
26
+ assert_equal @tool_step_option_ids, options
27
+ end
28
+ end
29
+
30
+ def test_that_can_return_rank_bigger_than_zero
31
+ VCR.use_cassette('test_results') do
32
+ @results = @gs.get_results(@tool_step_option_ids)
33
+ max_result = @results[:steps][0][:tool_groups].collect{|tg|
34
+ tg[:rankings].collect{|r| r[:calculated_rank]}
35
+ }.flatten!.max
36
+ assert_equal max_result, 2000
37
+ end
38
+ end
39
+
40
+ end
data/test/vcr_setup.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'vcr'
2
2
 
3
3
  VCR.configure do |c|
4
- c.cassette_library_dir = 'vcr_cassettes'
5
- c.hook_into :fakeweb
4
+ c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
5
+ c.hook_into :webmock
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goldshark_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,69 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-14 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: libxml-ruby
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
14
46
  description: A gem to interact with iGodigital GoldShark API
15
47
  email:
16
48
  - groselli@igodigital.com
17
49
  executables: []
18
50
  extensions: []
19
- extra_rdoc_files: []
51
+ extra_rdoc_files:
52
+ - README.md
20
53
  files:
21
54
  - .document
22
55
  - .gitignore
23
56
  - Gemfile
24
57
  - Gemfile.lock
25
58
  - LICENSE.txt
26
- - README
27
- - README.rdoc
59
+ - README.md
28
60
  - Rakefile
29
61
  - goldshark_gem.gemspec
30
62
  - lib/goldshark_gem.rb
31
- - test/goldshark_gem_test.rb
63
+ - lib/goldshark_gem/ci.rb
64
+ - lib/goldshark_gem/text.rb
65
+ - lib/goldshark_gem/tool.rb
66
+ - test/ci_test.rb
67
+ - test/fixtures/vcr_cassettes/test_channel_intelligence.yml
68
+ - test/fixtures/vcr_cassettes/test_results.yml
69
+ - test/fixtures/vcr_cassettes/test_text.yml
70
+ - test/fixtures/vcr_cassettes/test_tool.yml
32
71
  - test/helper.rb
72
+ - test/text_test.rb
73
+ - test/tool_test.rb
33
74
  - test/vcr_setup.rb
34
- - vcr_cassettes/.DS_Store
35
- - vcr_cassettes/test_tool.yml
36
75
  homepage:
37
76
  licenses: []
38
77
  post_install_message:
data/README DELETED
@@ -1,124 +0,0 @@
1
- = goldshark_gem
2
-
3
- gem install goldshark_gem
4
-
5
- in Gemfile:
6
-
7
- gem 'goldshark_gem'
8
-
9
- Initialization:
10
-
11
- gs = GS::Tool.new(localization)
12
- texts = GS::Text.new(localization)
13
-
14
- localization is the parameter key you will need to define in the YAML file. The config file has to be named 'tool_config.yml' and placed in the config folder of the Rails app.
15
-
16
- localization = 'en_us' or 'fridge_finder' or whatever you want it to be
17
-
18
- YAML file Sample (tool_config.yml)
19
-
20
- en_us:
21
- tool_guid: '12343252'
22
- locale: 'en'
23
- api_root: 'http://gst.api.igodigital.com/v2_2' # this option is optional it gsaults to v2_2
24
-
25
- fridge_finder:
26
- tool_guid: '3255423'
27
- locale: 'en'
28
- api_root: 'http://gst.api.igodigital.com/v2_2' # this option is optional it gsaults to v2_2
29
-
30
-
31
- If the tool_config.yml file is missing or you are not developing in the Rails enveironment. An empty object can be created and the variables can be defined like so:
32
-
33
- gs = GS::Tool.new
34
-
35
- gs.tool_guid('132424324')
36
- gs.session_id('92034802')
37
- gs.locale('en')
38
- gs.url('http://gst.api.igodigital.com/v2_2')
39
-
40
- texts = GS::Text.new
41
-
42
- texts.tool_guid('132424324')
43
- texts.locale('en')
44
-
45
- To retrieve the 'gs' object variables just call:
46
-
47
- gs.tool_guid or texts.tool_guid
48
- => '1233242'
49
-
50
- gs.session_id
51
- => '322342'
52
-
53
- gs.locale or texts.locale
54
- => 'en'
55
-
56
- gs.url
57
- => 'http://gst.api.igodigital.com/v2_2'
58
-
59
-
60
- All calls return hashes with symbolized keys and all product calls return a constant structure for the product object:
61
-
62
- Load and Search a text. After the text object is initialized. The find method returns the value as a string. (The text type is always defined unlike the text name so I picked that param to make the call).
63
-
64
- texts.load_texts
65
-
66
- text.find(text_type)
67
-
68
- Example:
69
-
70
- text.find('buy_now')
71
- => 'Buy Now'
72
-
73
- Grab the tool object with session id if defined, without session id if not defined.
74
-
75
- gs.get_tool
76
-
77
- This call accepts an array of tool step option ids and returns the results tool object.
78
-
79
- gs.get_results(tool_step_option_ids)
80
-
81
- This call accepts one skus or a string of comma separated values of skus and returns a products array.
82
-
83
- gs.get_products_by_skus(skus)
84
-
85
- This call accepts one retailer_product_id or a string of comma separated values of retailer_product_ids and returns a products array.
86
-
87
- gs.get_products_by_product_ids(product_ids)
88
-
89
- This call accepts an attribute name and returns an array of the requested attribute for all products.
90
-
91
- gs.get_attribute_by_name(attribute_name)
92
-
93
- This call will return all products linked to the retailer_product_id listed.
94
-
95
- gs.get_product_links(retailer_product_id)
96
-
97
- This call will return the user data of the gs.session_id. The user_id param is optional.
98
-
99
- gs.get_user_data(user_id)
100
-
101
- This call accepts session_data (it can be anything you want to save). And it save it to the user data.
102
-
103
- gs.save_user_data(session_data, user_id)
104
-
105
- This call records recommendation based on the gs.session_id. You will need to pass the group id and the retailer product list (not optional).
106
-
107
- gs.recs(group_id, retailer_product_list)
108
-
109
- This call will record the event passed on the gs.session_id.
110
-
111
- gs.record_events(event_name)
112
-
113
- This call will record microconversion based on the gs.session_id and the retailer product id passed (param not optional).
114
- gs.micro_convert(retailer_product_id)
115
-
116
- == Contributing to goldshark_gem
117
-
118
- Gabriele Roselli
119
-
120
- == Copyright
121
-
122
- Copyright (c) 2012 iGoDigital. See LICENSE.txt for
123
- further details.
124
-
data/README.rdoc DELETED
@@ -1,124 +0,0 @@
1
- = goldshark_gem
2
-
3
- gem install goldshark_gem
4
-
5
- in Gemfile:
6
-
7
- gem 'goldshark_gem'
8
-
9
- Initialization:
10
-
11
- gs = GS::Tool.new(localization)
12
- texts = GS::Text.new(localization)
13
-
14
- localization is the parameter key you will need to define in the YAML file. The config file has to be named 'tool_config.yml' and placed in the config folder of the Rails app.
15
-
16
- localization = 'en_us' or 'fridge_finder' or whatever you want it to be
17
-
18
- YAML file Sample (tool_config.yml)
19
-
20
- en_us:
21
- tool_guid: '12343252'
22
- locale: 'en'
23
- api_root: 'http://gst.api.igodigital.com/v2_2' # this option is optional it gsaults to v2_2
24
-
25
- fridge_finder:
26
- tool_guid: '3255423'
27
- locale: 'en'
28
- api_root: 'http://gst.api.igodigital.com/v2_2' # this option is optional it gsaults to v2_2
29
-
30
-
31
- If the tool_config.yml file is missing or you are not developing in the Rails enveironment. An empty object can be created and the variables can be defined like so:
32
-
33
- gs = GS::Tool.new
34
-
35
- gs.tool_guid('132424324')
36
- gs.session_id('92034802')
37
- gs.locale('en')
38
- gs.url('http://gst.api.igodigital.com/v2_2')
39
-
40
- texts = GS::Text.new
41
-
42
- texts.tool_guid('132424324')
43
- texts.locale('en')
44
-
45
- To retrieve the 'gs' object variables just call:
46
-
47
- gs.tool_guid or texts.tool_guid
48
- => '1233242'
49
-
50
- gs.session_id
51
- => '322342'
52
-
53
- gs.locale or texts.locale
54
- => 'en'
55
-
56
- gs.url
57
- => 'http://gst.api.igodigital.com/v2_2'
58
-
59
-
60
- All calls return hashes with symbolized keys and all product calls return a constant structure for the product object:
61
-
62
- Load and Search a text. After the text object is initialized. The find method returns the value as a string. (The text type is always defined unlike the text name so I picked that param to make the call).
63
-
64
- texts.load_texts
65
-
66
- text.find(text_type)
67
-
68
- Example:
69
-
70
- text.find('buy_now')
71
- => 'Buy Now'
72
-
73
- Grab the tool object with session id if defined, without session id if not defined.
74
-
75
- gs.get_tool
76
-
77
- This call accepts an array of tool step option ids and returns the results tool object.
78
-
79
- gs.get_results(tool_step_option_ids)
80
-
81
- This call accepts one skus or a string of comma separated values of skus and returns a products array.
82
-
83
- gs.get_products_by_skus(skus)
84
-
85
- This call accepts one retailer_product_id or a string of comma separated values of retailer_product_ids and returns a products array.
86
-
87
- gs.get_products_by_product_ids(product_ids)
88
-
89
- This call accepts an attribute name and returns an array of the requested attribute for all products.
90
-
91
- gs.get_attribute_by_name(attribute_name)
92
-
93
- This call will return all products linked to the retailer_product_id listed.
94
-
95
- gs.get_product_links(retailer_product_id)
96
-
97
- This call will return the user data of the gs.session_id. The user_id param is optional.
98
-
99
- gs.get_user_data(user_id)
100
-
101
- This call accepts session_data (it can be anything you want to save). And it save it to the user data.
102
-
103
- gs.save_user_data(session_data, user_id)
104
-
105
- This call records recommendation based on the gs.session_id. You will need to pass the group id and the retailer product list (not optional).
106
-
107
- gs.recs(group_id, retailer_product_list)
108
-
109
- This call will record the event passed on the gs.session_id.
110
-
111
- gs.record_events(event_name)
112
-
113
- This call will record microconversion based on the gs.session_id and the retailer product id passed (param not optional).
114
- gs.micro_convert(retailer_product_id)
115
-
116
- == Contributing to goldshark_gem
117
-
118
- Gabriele Roselli
119
-
120
- == Copyright
121
-
122
- Copyright (c) 2012 iGoDigital. See LICENSE.txt for
123
- further details.
124
-