alpha_card 0.2.2 → 0.2.3

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: ceec62767933ce8b3848b21ec0ffbe6c9775f229
4
- data.tar.gz: 82c414eea55aa6d675d0c1043cba408eb21af70a
3
+ metadata.gz: 4c5e5fb8c704ad1100003d8eb8023a7adf9c782d
4
+ data.tar.gz: 8207975985e90e9287e360eccda6ffdc649a0cba
5
5
  SHA512:
6
- metadata.gz: dac21d71195b11f35c375c1ea0743cf033f33e81eaa61ce639fdc5aedecf6ac5450ad139527233e18484fdb0a1ebccb223d843ef296a6b416318f84f16d547e2
7
- data.tar.gz: 3e713b2ccbd597e73a1f4c6bcc0faedab7e49e5fb9ec3319b3812d34c8fd74d1ecf3c3e78464df9c34bce9815f6daacc5c474caefca33a887cf7b8b4b613569e
6
+ metadata.gz: 6eb401a030e241fa9345168a1efe3dbcfdb26b1a3a4a8cb490bc6d94013cfdfc22ff029e753bdcc1e7e6854b57a6a0afd91c6263a4644a7c30da437c2f1ff5ab
7
+ data.tar.gz: 63c3e4f5fa8936433ad872e45e652357f4c773f8b3a003eb9dc75abcc2edf7f59e078fee5e0df6e62c5691d7651c212171d4638b4ca66f5db7c35fea11c6ed3c
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,17 +1,17 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
2
 
3
3
  require 'alpha_card/version'
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'alpha_card'
7
7
  gem.version = AlphaCard::VERSION
8
- gem.date = '2014-07-11'
8
+ gem.date = '2014-07-24'
9
9
  gem.summary = 'Alpha Card Services DirectPost API for Ruby'
10
10
  gem.description = 'Gem for creating sales with Alpha Card Services DirectPost API'
11
11
  gem.authors = ['Nikita Bulaj']
12
12
  gem.email = 'bulajnikita@gmail.com'
13
- gem.require_paths = ["lib"]
14
- gem.files = `git ls-files`.split($/)
13
+ gem.require_paths = ['lib']
14
+ gem.files = `git ls-files`.split($RS)
15
15
  gem.homepage = 'http://github.com/budev/alpha_card'
16
16
  gem.license = 'MIT'
17
17
  gem.required_ruby_version = '>= 1.9.3'
@@ -19,5 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency 'virtus', '~> 1.0'
20
20
  gem.add_dependency 'rest_client', '~> 1.7'
21
21
 
22
- gem.add_development_dependency "rspec", '~> 3'
22
+ gem.add_development_dependency 'rspec', '~> 3'
23
23
  end
@@ -83,9 +83,7 @@ module AlphaCard
83
83
  #
84
84
  # #=> AlphaCard::AlphaCardError: AlphaCard::AlphaCardError
85
85
  def self.request(params = {}, account)
86
- unless account.filled?
87
- raise AlphaCardError.new('You must set credentials to create the sale!')
88
- end
86
+ fail AlphaCardError, 'You must set credentials to create the sale!' unless account.filled?
89
87
 
90
88
  begin
91
89
  response = RestClient.post(@api_base, params.merge(account.attributes))
@@ -130,22 +128,21 @@ module AlphaCard
130
128
  #
131
129
  # @raise [AlphaCard::AlphaCardError]
132
130
  # AlphaCardError Exception.
133
- def self.handle_connection_errors(e)
134
- case e
135
- when RestClient::ServerBrokeConnection, RestClient::RequestTimeout
136
- message = "Could not connect to Alpha Card Gateway (#{@api_base}). " +
137
- 'Please check your internet connection and try again. ' +
138
- 'If this problem persists, you should check Alpha Card services status.'
139
-
140
- when SocketError
141
- message = 'Unexpected error communicating when trying to connect to Alpha Card Gateway. ' +
142
- 'You may be seeing this message because your DNS is not working.'
143
-
144
- else
145
- message = 'Unexpected error communicating with Alpha Card Gateway.'
131
+ def self.handle_connection_errors(error)
132
+ case error
133
+ when RestClient::ServerBrokeConnection, RestClient::RequestTimeout
134
+ message = "Could not connect to Alpha Card Gateway (#{@api_base}). " \
135
+ 'Please check your internet connection and try again. ' \
136
+ 'If this problem persists, you should check Alpha Card services status.'
137
+
138
+ when SocketError
139
+ message = 'Unexpected error communicating when trying to connect to Alpha Card Gateway. ' \
140
+ 'You may be seeing this message because your DNS is not working.'
141
+
142
+ else
143
+ message = 'Unexpected error communicating with Alpha Card Gateway.'
146
144
  end
147
145
 
148
- raise APIConnectionError.new(message + "\n\n(Network error: #{e.message})")
146
+ raise APIConnectionError, "#{message}\n\n(Network error: #{error.message})"
149
147
  end
150
148
  end
151
-
@@ -1,7 +1,7 @@
1
1
  module AlphaCard
2
2
  ##
3
3
  # Implementation of Alpha Card Services account object.
4
- # Contains credentials (username and password) for
4
+ # Contains credentials (username and password) for
5
5
  # the Alpha Card Gateway API access.
6
6
  class Account < AlphaCardObject
7
7
  attribute :username, String
@@ -42,7 +42,7 @@ module AlphaCard
42
42
  # #=> false
43
43
  def filled?
44
44
  attrs = [username, password]
45
- !attrs.empty? && attrs.all? {|attr| attr && !attr.strip.empty? }
45
+ !attrs.empty? && attrs.all? { |attr| attr && !attr.strip.empty? }
46
46
  end
47
47
  end
48
- end
48
+ end
@@ -18,7 +18,7 @@ module AlphaCard
18
18
  #
19
19
  # #=> {orderid: '1', ponumber: 'PO123'}
20
20
  def filled_attributes
21
- self.attributes.select { |_, value| !value.nil? }
21
+ attributes.select { |_, value| !value.nil? }
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -128,4 +128,4 @@ module AlphaCard
128
128
  @data['response'] == ERROR
129
129
  end
130
130
  end
131
- end
131
+ end
@@ -17,4 +17,4 @@ module AlphaCard
17
17
  attribute :fax, String
18
18
  attribute :website, String
19
19
  end
20
- end
20
+ end
@@ -12,4 +12,4 @@ module AlphaCard
12
12
  attribute :billing, AlphaCard::Billing
13
13
  attribute :shipping, AlphaCard::Shipping
14
14
  end
15
- end
15
+ end
@@ -41,13 +41,15 @@ module AlphaCard
41
41
  # #=> true
42
42
  def create(order, account)
43
43
  [:ccexp, :ccnumber, :amount].each do |attr|
44
- raise Exception.new("No #{attr} information provided") if self[attr].nil? || self[attr].empty?
44
+ fail Exception, "No #{attr} information provided" if self[attr].nil? || self[attr].empty?
45
45
  end
46
46
 
47
- params = self.filled_attributes || {}
48
- [order, order.billing, order.shipping].compact.each { |obj| params.merge!(obj ? obj.filled_attributes : {}) }
47
+ params = filled_attributes || {}
48
+ [order, order.billing, order.shipping].compact.each do |obj|
49
+ params.merge!(obj ? obj.filled_attributes : {})
50
+ end
49
51
 
50
52
  AlphaCard.request(params, account).success?
51
53
  end
52
54
  end
53
- end
55
+ end
@@ -16,7 +16,7 @@ module AlphaCard
16
16
 
17
17
  ##
18
18
  # Overloaded <code>filled_attributes</code> method from
19
- # <code>AlphaCard::AlphaCardObject</code>. All attributes of
19
+ # <code>AlphaCard::AlphaCardObject</code>. All attribute names of
20
20
  # the Alpha Card Shipping object must start with "shipping_"
21
21
  # prefix.
22
22
  #
@@ -29,7 +29,7 @@ module AlphaCard
29
29
  #
30
30
  # #=> {shipping_firstname: 'John', shipping_state: 'NY'}
31
31
  def filled_attributes
32
- Hash[super.map {|k, v| ["shipping_#{k}".to_sym, v] }]
32
+ Hash[super.map { |k, v| ["shipping_#{k}".to_sym, v] }]
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -40,7 +40,7 @@ module AlphaCard
40
40
  # Parse query string to a <code>Hash</code> by breaking it up
41
41
  # at the '&' and ';' characters.
42
42
  #
43
- # @param [String] qs
43
+ # @param [String] query
44
44
  # query string
45
45
  # @param [String] d
46
46
  # delimiter for the params
@@ -56,12 +56,12 @@ module AlphaCard
56
56
  #
57
57
  # query = AlphaCard::Utils.parse_query("cars[]=Saab&cars[]=Audi")
58
58
  # #=> {"cars[]"=>["Saab", "Audi"]}
59
- def parse_query(qs, d = nil, &unescaper)
59
+ def parse_query(query, d = nil, &unescaper)
60
60
  unescaper ||= method(:unescape)
61
61
 
62
62
  params = {}
63
63
 
64
- (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
64
+ (query || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
65
65
  next if p.empty?
66
66
  k, v = p.split('=', 2).map(&unescaper)
67
67
 
@@ -80,4 +80,4 @@ module AlphaCard
80
80
  end
81
81
  end
82
82
  end
83
- end
83
+ end
@@ -1,5 +1,5 @@
1
1
  module AlphaCard
2
2
  ##
3
3
  # Version information for AlphaCard gem.
4
- VERSION = '0.2.2'
5
- end
4
+ VERSION = '0.2.3'
5
+ end
@@ -15,4 +15,4 @@ describe AlphaCard::Account do
15
15
  expect(invalid_account.filled?).to be_falsey
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -60,4 +60,4 @@ describe AlphaCard::AlphaCardResponse do
60
60
  expect(response.transaction_id).to eq('2302620041')
61
61
  end
62
62
  end
63
- end
63
+ end
@@ -111,4 +111,4 @@ describe AlphaCard do
111
111
  end
112
112
  end
113
113
  end
114
- end
114
+ end
@@ -22,4 +22,4 @@ describe AlphaCard::Utils do
22
22
  expect(AlphaCard::Utils.unescape("a%20space")).to eq("a space")
23
23
  expect(AlphaCard::Utils.unescape("q1%212%22%27w%245%267%2Fz8%29%3F%5C")).to eq("q1!2\"'w$5&7/z8)?\\")
24
24
  end
25
- end
25
+ end
@@ -8,4 +8,4 @@ require 'alpha_card'
8
8
 
9
9
  RSpec.configure do |config|
10
10
  config.order = 'random'
11
- end
11
+ 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.2.2
4
+ version: 0.2.3
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-11 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus