BnmAPI 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc66d3951b21035682a2b4b2f6ea0b4da1096d0d0e97b673c8882ed170181a3c
4
- data.tar.gz: 6e1297d73b069c1b246010dd55569923f9331703663e4c64b1ff892f708486c7
3
+ metadata.gz: 4e807a48dfef08fab1c7ff16cbf87ef4fa4126b88db25fd89845bca0ce30b7cb
4
+ data.tar.gz: 6f1a037f5240ee78464a746173d1d34a3496ffcf18890ca3cd635835524eaa80
5
5
  SHA512:
6
- metadata.gz: 5ac8cdb7b96ecf0f4579d99d2cf487cc0eba8bf54f0be6af3fc0b1e604fa47c2595b9c82756fecf14518669ad5081c1f41ed33a715a5efa7ed899ddd2ba0ab91
7
- data.tar.gz: e99bfa3283a5c872ef932bcfd1084a16299410905f51bc54304e159d04066b0a92e66de288a24ded7e5237f53170482542eb6fb0a2cdf42edb3cb9b54acd5c5e
6
+ metadata.gz: bc11fd9bc51ca071f3e1981825d8b05fb64a6da0dd8be77a35574670ba913dd113a02211445ef218b479b7566197342770c799b993f0a1ffdfc9ab25cbedef36
7
+ data.tar.gz: 9a484fbdcac03ee856ed1e8b6961e835217a02bfeaaadbfd9e3087182108791070d2dd8c3ca573d6535d52679d8df673dcb9f797814fd062d78ce6497fa4bc12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- BnmAPI (0.0.1)
4
+ BnmAPI (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/bnmapi.gemspec CHANGED
@@ -14,26 +14,6 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/jibone/bnmapi"
15
15
  spec.license = "MIT"
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- #if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
-
22
- # spec.metadata["homepage_uri"] = spec.homepage
23
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
- #else
26
- # raise "RubyGems 2.0 or newer is required to protect against " \
27
- # "public gem pushes."
28
- #end
29
-
30
- ## Specify which files should be added to the gem when it is released.
31
- ## The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
- #spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
- # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
- #end
35
- #spec.bindir = "exe"
36
- #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
38
18
  f.match(%r{^(test|spec|features)/})
39
19
  end
@@ -49,5 +29,4 @@ Gem::Specification.new do |spec|
49
29
  spec.add_development_dependency "rspec", "~> 3.0"
50
30
  spec.add_development_dependency 'webmock'
51
31
  spec.add_development_dependency 'vcr'
52
-
53
32
  end
@@ -28,7 +28,12 @@ module BnmAPI
28
28
  def self.by_bank_code(bank_code)
29
29
  http = BnmAPI::HTTP::Client.new(endpoint: ENDPOINT + '/' + bank_code)
30
30
 
31
- res = JSON.parse(http.request.read_body)
31
+ response = http.request
32
+ if response.code == '404'
33
+ raise BnmAPI::Error::InvalidBankCode.new(bank_code: bank_code)
34
+ end
35
+
36
+ res = JSON.parse(response.read_body)
32
37
 
33
38
  BnmAPI::Data::BankBaseRate.new(
34
39
  res['data']['bank_code'],
@@ -0,0 +1,10 @@
1
+ module BnmAPI::Error
2
+ class InvalidBankCode < StandardError
3
+ attr_reader :bank_code
4
+
5
+ def initialize(msg: 'Invalid bank code', bank_code:)
6
+ @bank_code = bank_code
7
+ super(msg + ': ' + bank_code)
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module BnmAPI
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/bnmapi.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'bnmapi/version'
2
2
  require 'bnmapi/http/client'
3
3
  require 'bnmapi/data/bank_base_rate'
4
+ require 'bnmapi/error/invalid_bank_code'
4
5
  require 'bnmapi/welcome'
5
6
  require 'bnmapi/base_rate'
6
7
 
7
8
  module BnmAPI
8
- class Error < StandardError; end
9
9
  # Your code goes here...
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BnmAPI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Shamsul Bahri (jibone))
@@ -104,6 +104,7 @@ files:
104
104
  - lib/bnmapi.rb
105
105
  - lib/bnmapi/base_rate.rb
106
106
  - lib/bnmapi/data/bank_base_rate.rb
107
+ - lib/bnmapi/error/invalid_bank_code.rb
107
108
  - lib/bnmapi/http/client.rb
108
109
  - lib/bnmapi/version.rb
109
110
  - lib/bnmapi/welcome.rb