customer_score 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/Rakefile +5 -0
- data/customer_score.gemspec +2 -0
- data/lib/customer_score/version.rb +1 -1
- data/lib/customer_score.rb +17 -7
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b966b93d0b8287473dd8ef25f61d334af7058b9
|
4
|
+
data.tar.gz: fe94e3d98f237a6829c75fa71a43be5b751302c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1fe8128094ef083285ad125d1c1da922b7e9e79dde2b52f1c8d516ca9869fc79367fdd7f58ef0cb3ecc38482fb0bce4240c843d2610b60548f609e43696dfb2
|
7
|
+
data.tar.gz: c994562ecef0698a431c0747360112628b618c4635aa6ca434da3ef942bc309dd7524b4ccce14c307abb8b758ddcff700a214bd7ecde7d4e0dfc3f0916647e2a
|
data/README.md
CHANGED
@@ -32,15 +32,13 @@ To retrieve scoring advice for a customer based on their income, zipcode, and ag
|
|
32
32
|
|
33
33
|
````ruby
|
34
34
|
score = client.get_score("5000", "60201", "35")
|
35
|
-
#=>
|
35
|
+
#=> {:propensity => 0.26532, :ranking => "C"}
|
36
36
|
```
|
37
37
|
|
38
38
|
|
39
|
-
##
|
39
|
+
## Testing
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
41
|
+
To run tests, run `rake spec` in your console.
|
44
42
|
|
45
43
|
## Contributing
|
46
44
|
|
data/Rakefile
CHANGED
data/customer_score.gemspec
CHANGED
data/lib/customer_score.rb
CHANGED
@@ -3,28 +3,38 @@ require "unirest"
|
|
3
3
|
|
4
4
|
module CustomerScore
|
5
5
|
class Client
|
6
|
+
|
6
7
|
def initialize()
|
7
8
|
@default_url = "http://not_real.com/customer_scoring"
|
8
9
|
end
|
9
10
|
|
10
11
|
def get_score(income, zipcode, age)
|
12
|
+
|
13
|
+
return "Please provide a valid income (no commas or decimals)" unless income.to_s !~ /\d+[,.]\d+/
|
14
|
+
return "Please provide a valid 6 or 10 digit zipcode" if zipcode.to_s !~ /^\d{5}(-\d{4})?$/
|
15
|
+
return "Please provide a valid age" unless age.to_s !~ /\d+[,.]\d+/
|
16
|
+
|
11
17
|
url = "#{@default_url}?income=#{income}&zipcode=#{zipcode}&age=#{age}"
|
12
|
-
|
18
|
+
|
19
|
+
case status = get_status(url)
|
13
20
|
when 200
|
14
21
|
return Unirest.get(url).body
|
15
22
|
when 404
|
16
|
-
raise ResourceNotFound, "
|
17
|
-
when 422
|
18
|
-
raise InvalidInput, "Unprocessable Entity"
|
23
|
+
raise ResourceNotFound, "The specified resource does not exist"
|
19
24
|
when 500
|
20
|
-
raise InternalError, "
|
25
|
+
raise InternalError, "The server encountered an internal error, please retry the request"
|
21
26
|
else
|
22
|
-
raise "Error"
|
27
|
+
raise "Error, your request was not completed"
|
23
28
|
end
|
24
29
|
end
|
30
|
+
|
31
|
+
def get_status(url)
|
32
|
+
Unirest.get(url).code
|
33
|
+
end
|
34
|
+
|
25
35
|
end
|
26
36
|
|
27
37
|
class ResourceNotFound < Exception; end
|
28
|
-
class InvalidInput < Exception; end
|
29
38
|
class InternalError < Exception; end
|
39
|
+
|
30
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: customer_score
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zoe heins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.1.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.14.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.14.0
|
55
69
|
description: Allows you to access scoring advice on customer
|
56
70
|
email:
|
57
71
|
- zcheins@gmail.com
|