flinks 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flinks.gemspec +2 -2
- data/lib/flinks/api/card.rb +3 -1
- data/lib/flinks/error.rb +7 -11
- data/lib/flinks/request.rb +12 -3
- data/spec/lib/api/card_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b40e64a6fdd3224f7d5a86a3502d1e5a02fdff126185d423242344cab8c258b
|
4
|
+
data.tar.gz: 0aa9f408a0dd6035c12b2c8d19c0bae39fc36cc0067ad6a418fafa03a7a087af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5327ea28eb69a990f2ec97bf598f575c59782dfe994370802f142489aee171749d02b85c5b70f4479960ad5c40b7f33ce0aa79a9ee164065adb20080d85496e7
|
7
|
+
data.tar.gz: af1c6fef96e05380e20391394fce5687a2f79d2d8204ca29f8bf9d97b92d87d45a911c00c11f50637e3600967818fa7fe506ae732b61b2ca34deca5849340d95
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.2
|
data/flinks.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flinks 0.5.
|
5
|
+
# stub: flinks 0.5.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flinks".freeze
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
data/lib/flinks/api/card.rb
CHANGED
@@ -8,7 +8,9 @@ module Flinks
|
|
8
8
|
# @param [String] login_id
|
9
9
|
# @return [Hash]
|
10
10
|
def delete_card(login_id:)
|
11
|
-
delete("#{customer_id}/BankingServices/DeleteCard/#{login_id}")
|
11
|
+
delete("#{customer_id}/BankingServices/DeleteCard/#{login_id}").tap do |response|
|
12
|
+
raise Flinks::NotFound, "Invalid LoginId" if response.match(/Invalid LoginId/)
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
data/lib/flinks/error.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Flinks
|
4
4
|
class Error < StandardError
|
5
|
-
|
5
|
+
attr_accessor :response, :code
|
6
6
|
|
7
7
|
# @param [HTTP::Response] response
|
8
8
|
# @return [Flinks::Error]
|
@@ -28,7 +28,11 @@ module Flinks
|
|
28
28
|
self
|
29
29
|
end
|
30
30
|
|
31
|
-
klass.new(response)
|
31
|
+
error = klass.new(build_message(response))
|
32
|
+
error.response = response
|
33
|
+
error.code = response.code
|
34
|
+
|
35
|
+
error
|
32
36
|
end
|
33
37
|
|
34
38
|
# @param [HTTP::Response] response
|
@@ -62,16 +66,8 @@ module Flinks
|
|
62
66
|
end
|
63
67
|
|
64
68
|
# @param [HTTP::Response] response
|
65
|
-
# @return [Flinks::Error]
|
66
|
-
def initialize(response)
|
67
|
-
@response = response
|
68
|
-
@code = response.code
|
69
|
-
|
70
|
-
super(build_message)
|
71
|
-
end
|
72
|
-
|
73
69
|
# @return [String]
|
74
|
-
def build_message
|
70
|
+
def self.build_message(response)
|
75
71
|
message = response.parse['Message']
|
76
72
|
message << " - FlinksCode: #{response.parse['FlinksCode']}"
|
77
73
|
rescue HTTP::Error
|
data/lib/flinks/request.rb
CHANGED
@@ -34,6 +34,15 @@ module Flinks
|
|
34
34
|
request(:patch, path, params: params, body: body)
|
35
35
|
end
|
36
36
|
|
37
|
+
# Performs a HTTP Delete request
|
38
|
+
#
|
39
|
+
# @param [String] path
|
40
|
+
# @param [Hash] params
|
41
|
+
# @param [Hash] body
|
42
|
+
def delete(path, params: {}, body: {})
|
43
|
+
request(:delete, path, params: params, body: body)
|
44
|
+
end
|
45
|
+
|
37
46
|
|
38
47
|
private
|
39
48
|
|
@@ -74,10 +83,10 @@ module Flinks
|
|
74
83
|
data = response.parse
|
75
84
|
|
76
85
|
# Transform data
|
77
|
-
if raw
|
78
|
-
data
|
79
|
-
else
|
86
|
+
if !raw && raw.is_a?(Hash)
|
80
87
|
data.deep_transform_keys { |k| k.underscore }.with_indifferent_access
|
88
|
+
else
|
89
|
+
data
|
81
90
|
end
|
82
91
|
end
|
83
92
|
end
|
data/spec/lib/api/card_spec.rb
CHANGED
@@ -3,16 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe Flinks::API::Card do
|
4
4
|
let(:api_endpoint) { Flinks::Client.dry_initializer.definitions[:api_endpoint].default.call }
|
5
5
|
let(:client) { Flinks.new(customer_id: 'customer_id') }
|
6
|
-
let(:
|
6
|
+
let(:login_id) { 'login_id' }
|
7
7
|
|
8
8
|
describe '#delete_card' do
|
9
9
|
before do
|
10
|
-
stub_request(:
|
10
|
+
stub_request(:delete, /#{api_endpoint}/)
|
11
11
|
.to_return(status: 200, body: "{}", headers: { 'Content-Type'=>'application/json' })
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns an object" do
|
15
|
-
expect(client.delete_card(
|
15
|
+
expect(client.delete_card(login_id: login_id)).to be_a(Hash)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|