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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f08c8c228668114a834da0d41b8eebf31a40a909
4
- data.tar.gz: f70224278aa293022e5afd8fbf2ff84be51d3608
3
+ metadata.gz: 6b966b93d0b8287473dd8ef25f61d334af7058b9
4
+ data.tar.gz: fe94e3d98f237a6829c75fa71a43be5b751302c8
5
5
  SHA512:
6
- metadata.gz: cd9589c7151c80694fdfa0828d8f285e62184d0f6ee7f2049439f5a73ca8c64eeb3b8c976abb25c3cd2b082a0e51b44ba11c683bea8f690f97a3ee7bb2b74ab2
7
- data.tar.gz: 390723c31409e765e94400f2d33217099fbcd854871140f673a723834e6e4003e2a17d017bf83890b351d36d61aa352c4998bbcdeec245a72897787705d322e6
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
- #=> "{:propensity => 0.26532, :ranking => "C"}"
35
+ #=> {:propensity => 0.26532, :ranking => "C"}
36
36
  ```
37
37
 
38
38
 
39
- ## Development
39
+ ## Testing
40
40
 
41
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+
5
+ RSpec::Core::RakeTask.new
6
+ task :default => :spec
@@ -30,4 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "bundler", "~> 1.10"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_dependency 'unirest', "~> 1.1.2"
33
+ spec.add_development_dependency "webmock", "~> 1.14.0"
34
+
33
35
  end
@@ -1,3 +1,3 @@
1
1
  module CustomerScore
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
- case status = Unirest.get(url).code
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, "Invalid URL"
17
- when 422
18
- raise InvalidInput, "Unprocessable Entity"
23
+ raise ResourceNotFound, "The specified resource does not exist"
19
24
  when 500
20
- raise InternalError, "Internal Server Error"
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.0
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 00:00:00.000000000 Z
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