alpha_card 0.1.9 → 0.2.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
  SHA1:
3
- metadata.gz: 9578c7b0b9b2681146ac0370640b26ed9b6d7cd4
4
- data.tar.gz: a9ade4a67954c16fc8c3bff0dd8b92838b820358
3
+ metadata.gz: 76fc164bc35261fa54520d3d411288fe4dac224e
4
+ data.tar.gz: fa87d69a8a812fca096d22e394c82ea9ef4f31cb
5
5
  SHA512:
6
- metadata.gz: d9e4b44f63a547a82f1c4a4fd405790436fa663bb31aabe3ba22c995cccc5b7333b0c6f25c4bdc2802209e29c03141899d8bd1df5ed9fa95917c769eb6663a42
7
- data.tar.gz: bff105616d044b9560ed7f53dc2b47702134b2aa4d3fc86f2a7939abadccebea6bcd9569b8210151f4456f817c6ffb7520c796c970fb8ddc301f5ab13cae47c5
6
+ metadata.gz: 5e354992f043c879b4b6f12e931417dba4356b19ad757223b875f98d00f89a50d0281b514c0c0b20aa793727da396ba760d17ae05704849033ed9ef1c0ef1a4b
7
+ data.tar.gz: c9533e52a55e8ab79b447c32e55e15fffe4e38064e9cd1850ddefb706c4fd3567ee8345aa2fff0d924dfa81842921674f8608fe18674078052970a89ae3dc04b
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'alpha_card'
3
- gem.version = '0.1.9'
4
- gem.date = '2014-07-02'
3
+ gem.version = '0.2.0'
4
+ gem.date = '2014-07-09'
5
5
  gem.summary = 'Alpha Card Services DirectPost API for Ruby'
6
6
  gem.description = 'Gem for creating sales with Alpha Card Services DirectPost API'
7
7
  gem.authors = ['Nikita Bulaj']
@@ -6,7 +6,9 @@ require 'rest_client'
6
6
  require 'alpha_card/utils'
7
7
  require 'alpha_card/alpha_card_object'
8
8
  require 'alpha_card/alpha_card_response'
9
- require 'alpha_card/alpha_card_error'
9
+
10
+ require 'alpha_card/errors/alpha_card_error'
11
+ require 'alpha_card/errors/api_connection_error'
10
12
 
11
13
  require 'alpha_card/account'
12
14
  require 'alpha_card/shipping'
@@ -25,10 +27,10 @@ module AlphaCard
25
27
  # Global Payment Systems (NDC) Credit Card Authorization Codes
26
28
  #
27
29
  # @see http://floristwiki.ftdi.com/images/c/ce/Appendix_A_-_Credit_Card_Authorization_Codes.pdf Credit Card Authorization Codes
28
- CREDIT_CARD_CODES ||= YAML.load_file(File.expand_path('../alpha_card/data/codes.yml', __FILE__))
30
+ CREDIT_CARD_CODES ||= YAML.load_file(File.expand_path('../alpha_card/data/credit_card_codes.yml', __FILE__))
29
31
 
30
32
  class << self
31
- # @return [String] Alpha Card Gateway DirectPost API URL.
33
+ # @return [String] Alpha Card Gateway DirectPost API URL.
32
34
  attr_accessor :api_base
33
35
  end
34
36
 
@@ -99,7 +101,7 @@ module AlphaCard
99
101
  # Alpha Card Services response text.
100
102
  def self.handle_alpha_card_errors(response)
101
103
  code = response.text
102
- raise AlphaCardError.new(CREDIT_CARD_CODES[code] || code) unless response.success?
104
+ raise AlphaCardError.new(CREDIT_CARD_CODES[code] || code, response) unless response.success?
103
105
  end
104
106
 
105
107
  ##
@@ -126,7 +128,7 @@ module AlphaCard
126
128
  message = 'Unexpected error communicating with Alpha Card Gateway.'
127
129
  end
128
130
 
129
- raise AlphaCardError.new(message + "\n\n(Network error: #{e.message})")
131
+ raise APIConnectionError.new(message + "\n\n(Network error: #{e.message})")
130
132
  end
131
133
  end
132
134
 
@@ -80,7 +80,7 @@ module AlphaCard
80
80
  ##
81
81
  # Indicate the state of the request to the
82
82
  # Alpha Card Gateway. Returns <i>true</i> if
83
- # response was <i>approved</i>.
83
+ # request was <i>approved</i>.
84
84
  #
85
85
  # @return [Bool] true if request if successful
86
86
  #
@@ -97,7 +97,7 @@ module AlphaCard
97
97
  ##
98
98
  # Indicate the state of the request to the
99
99
  # Alpha Card Gateway. Returns <i>true</i> if
100
- # response was <i>declined</i>.
100
+ # request was <i>declined</i>.
101
101
  #
102
102
  # @return [Bool] true if request was declined
103
103
  #
@@ -114,7 +114,7 @@ module AlphaCard
114
114
  ##
115
115
  # Indicate the state of the request to the
116
116
  # Alpha Card Gateway. Returns <i>true</i> if
117
- # response has some <i>errors</i>.
117
+ # request has some <i>errors</i>.
118
118
  #
119
119
  # @return [Bool] true if request has some errors
120
120
  #
@@ -0,0 +1,23 @@
1
+ module AlphaCard
2
+ ##
3
+ # Common class for Alpha Card Gateway errors and exceptions.
4
+ class AlphaCardError < StandardError
5
+ attr_reader :response
6
+ attr_reader :message
7
+
8
+ ##
9
+ # <code>AlphaCard::AlphaCardError</code> constructor.
10
+ #
11
+ # @param [String] error message
12
+ # @param [AlphaCard::AlphaCardResponse] AlphaCard Gateway response
13
+ #
14
+ # @example
15
+ # AlphaCard::AlphaCardError.new
16
+ #
17
+ # #=> #<AlphaCard::AlphaCardError: AlphaCard::AlphaCardError>
18
+ def initialize(message = nil, response = nil)
19
+ @message = message
20
+ @response = response
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ module AlphaCard
2
+ ##
3
+ # Class for connection errors.
4
+ class APIConnectionError < StandardError
5
+ end
6
+ end
@@ -93,20 +93,20 @@ describe AlphaCard do
93
93
  let!(:socket_error) { SocketError.new }
94
94
  let!(:unclassified_error) { StandardError.new('Some error') }
95
95
 
96
- it 'should raise an Exception if Rest Client Error' do
97
- expect { AlphaCard.handle_connection_errors(rest_client_error) }.to raise_error(AlphaCard::AlphaCardError) do |e|
96
+ it 'should raise an APIConnectionError if Rest Client Error' do
97
+ expect { AlphaCard.handle_connection_errors(rest_client_error) }.to raise_error(AlphaCard::APIConnectionError) do |e|
98
98
  expect(e.message).to include('Could not connect to Alpha Card Gateway')
99
99
  end
100
100
  end
101
101
 
102
- it 'should raise an Exception if Socket Error' do
103
- expect { AlphaCard.handle_connection_errors(socket_error) }.to raise_error(AlphaCard::AlphaCardError) do |e|
102
+ it 'should raise an APIConnectionError if Socket Error' do
103
+ expect { AlphaCard.handle_connection_errors(socket_error) }.to raise_error(AlphaCard::APIConnectionError) do |e|
104
104
  expect(e.message).to include('Unexpected error communicating when trying to connect to Alpha Card Gateway')
105
105
  end
106
106
  end
107
107
 
108
- it 'should raise an Exception if Unclassified Error' do
109
- expect { AlphaCard.handle_connection_errors(unclassified_error) }.to raise_error(AlphaCard::AlphaCardError) do |e|
108
+ it 'should raise an APIConnectionError if Unclassified Error' do
109
+ expect { AlphaCard.handle_connection_errors(unclassified_error) }.to raise_error(AlphaCard::APIConnectionError) do |e|
110
110
  expect(e.message).to include('Unexpected error communicating with Alpha Card Gateway')
111
111
  end
112
112
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alpha_card
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Bulaj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -40,11 +40,12 @@ files:
40
40
  - alpha_card.gemspec
41
41
  - lib/alpha_card.rb
42
42
  - lib/alpha_card/account.rb
43
- - lib/alpha_card/alpha_card_error.rb
44
43
  - lib/alpha_card/alpha_card_object.rb
45
44
  - lib/alpha_card/alpha_card_response.rb
46
45
  - lib/alpha_card/billing.rb
47
- - lib/alpha_card/data/codes.yml
46
+ - lib/alpha_card/data/credit_card_codes.yml
47
+ - lib/alpha_card/errors/alpha_card_error.rb
48
+ - lib/alpha_card/errors/api_connection_error.rb
48
49
  - lib/alpha_card/order.rb
49
50
  - lib/alpha_card/sale.rb
50
51
  - lib/alpha_card/shipping.rb
@@ -1,6 +0,0 @@
1
- module AlphaCard
2
- ##
3
- # Class for Alpha Card Gateway errors and exceptions.
4
- class AlphaCardError < StandardError
5
- end
6
- end