leapfrog_consumer_score 0.0.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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +65 -0
  4. data/lib/consumer_score.rb +26 -0
  5. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b0c1c2c52677b4673aeb282dd8c834ec57235d23
4
+ data.tar.gz: 04dc423c62199aa9de8f6c4bd17d6929f8ec54f6
5
+ SHA512:
6
+ metadata.gz: eb55ac121c062508e74084d0985472e898ccfb520340ae9255bae8a55d22c28938e56440eac4713889fd30793796f8eaed251abbda88b96a4773f23c4b24dc9d
7
+ data.tar.gz: ff4f2d68e3e78a6f5dc7534d43b11ffc8274878d4d9b5704bd97fd997c3320f7031313258ee3be953f279880a192c61817d3283d81b237a266264803c13756e0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Kelmer Perez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ Leapfrog Consumer Score API wrapper
2
+ =========
3
+
4
+ This is a Ruby Gem that acts as a wrapper for Leapfrog Online's Consumer Score API.
5
+
6
+ Leapfrog's API provides scoring advice about a consumer based on their income, zip code and age.
7
+
8
+ Version
9
+ ----
10
+
11
+ 0.0.1
12
+
13
+ Dependencies
14
+ -----------
15
+
16
+ This gem uses a couple of open source projects to work properly:
17
+ * httparty [https://github.com/jnunemaker/httparty]
18
+
19
+ This dependency exists for running the rspec tests:
20
+ * fakeweb [https://github.com/chrisk/fakeweb]
21
+
22
+
23
+ Installation
24
+ --------------
25
+
26
+ ```ruby
27
+ gem install leapfrog_consumer_score
28
+ ```
29
+
30
+ Then require consumer_score in your project
31
+ ----------------
32
+
33
+ ```ruby
34
+ require 'consumer_score'
35
+ ```
36
+
37
+ Usage
38
+ --------------
39
+
40
+ ```ruby
41
+ score = ConsumerScore.new
42
+ income = 50000
43
+ zipcode = 60201
44
+ age = 35
45
+ score.get_score(income, zipcode, age) #{"propensity"=>0.26532, "ranking"=>"C"}
46
+ ```
47
+
48
+ Testing
49
+ ----------------
50
+ Clone the repo into a folder in your computer and run rpsec.
51
+
52
+ ```ruby
53
+ $> git clone https://github.com/kelmerp/leapfrog_consumer_score.git [yourfoldername]
54
+ $> bundle
55
+ $> cd [yourfoldername]
56
+ $> rspec
57
+ ```
58
+
59
+ License
60
+ ----
61
+
62
+ MIT
63
+
64
+ [kelmer perez]: http://kelmerp.github.io/
65
+ [@kelmerperez]: http://twitter.com/kelmerperez
@@ -0,0 +1,26 @@
1
+ require "httparty"
2
+ require "json"
3
+
4
+ class ConsumerScore
5
+
6
+ BASE_URL = "http://internal.leapfrogonline.com"
7
+
8
+ def get_score(income, zipcode, age)
9
+ begin
10
+ if income.class != Fixnum && income.class != Float
11
+ raise ArgumentError, "An error has occurred: please supply a valid income"
12
+ elsif !zipcode.to_s =~ /\d{5}/
13
+ raise ArgumentError, "An error has occurred: please supply a valid zip code"
14
+ elsif age.class != Fixnum
15
+ raise ArgumentError, "An error has occurred: please supply a valid age"
16
+ else
17
+ url = "#{BASE_URL}/consumer_scoring?income=#{income}&zipcode=#{zipcode}&age=#{age}"
18
+ response = HTTParty.get(url)
19
+ response.body
20
+ end
21
+ rescue Exception => e
22
+ e.message
23
+ end
24
+ end
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: leapfrog_consumer_score
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Kelmer Perez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Leapfrog Online Consumer Score API wrapper
14
+ email: kelmerp@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/consumer_score.rb
20
+ - LICENSE
21
+ - README.md
22
+ homepage: https://github.com/kelmerp/leapfrog_consumer_score
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.1.5
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Leapfog Consumer Score gem
46
+ test_files: []