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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 304cf08db5ce170b00ab1e0612aed08897782944311ffa712c4f166e635b5858
4
- data.tar.gz: 5ae67cbe3eb0e5bcd530d1393e36b0324dfd2a1030939b7ad68d1c035744ed00
3
+ metadata.gz: 6b40e64a6fdd3224f7d5a86a3502d1e5a02fdff126185d423242344cab8c258b
4
+ data.tar.gz: 0aa9f408a0dd6035c12b2c8d19c0bae39fc36cc0067ad6a418fafa03a7a087af
5
5
  SHA512:
6
- metadata.gz: e6f79ff1f8067e3fed0f85c625da31e749621e7e4ef8d420e1dca10ec0f8e8494d371b100899db4b18ba4ec6950501ca6179ad3e771d3ad12d673bc48b91c36f
7
- data.tar.gz: d362cfe96d541365a37b6138b5857889c0ee433e830ea05d0553285863a3bf8c33313d332aebed46cc13528e16d4f4d54dc520f6eb321110f7eb33888e4fef41
6
+ metadata.gz: 5327ea28eb69a990f2ec97bf598f575c59782dfe994370802f142489aee171749d02b85c5b70f4479960ad5c40b7f33ce0aa79a9ee164065adb20080d85496e7
7
+ data.tar.gz: af1c6fef96e05380e20391394fce5687a2f79d2d8204ca29f8bf9d97b92d87d45a911c00c11f50637e3600967818fa7fe506ae732b61b2ca34deca5849340d95
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -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.1 ruby lib
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.1"
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]
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Flinks
4
4
  class Error < StandardError
5
- attr_reader :response, :code
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
@@ -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
@@ -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(:card_id) { 'card_id' }
6
+ let(:login_id) { 'login_id' }
7
7
 
8
8
  describe '#delete_card' do
9
9
  before do
10
- stub_request(:get, /#{api_endpoint}/)
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(card_id: card_id)).to be_a(Hash)
15
+ expect(client.delete_card(login_id: login_id)).to be_a(Hash)
16
16
  end
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Dionne