moyasar 0.6.0 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 554e32ec1adefa67fc7e979cff1cdd8a164ec66d
4
- data.tar.gz: c54f854bc8c1908c0936d5471854a706fae64070
3
+ metadata.gz: 9862490dc56ef2b68ff1ef2360b90a2b82d5b0d2
4
+ data.tar.gz: 4e2d39952fb39caca9081bad50c672e33af2ab17
5
5
  SHA512:
6
- metadata.gz: d46e73cd154121bcefdf30f9499b6a2eb453dbe1bd992c8c65c9b5b20a08d5af76d3817d20810391443f770e85a5661b16796fc0052d3a4c16c70870491ede50
7
- data.tar.gz: a9c3a9746f8b3d4edba7f8192b8b739be45b6d363064003f3a3df19bf5ed8396ef71d8dbc892dbda7d192eb41d95af432701f42c93357f941032aab036b939a3
6
+ metadata.gz: 0e2681882484d94a8aa5ba8d958596e61166d5df21a17a32a96e0fcb92104b78b5cc5cf24049653758b6dafcfabde200b9fdfd1a0beef840fe0f0fd1ea2eb7a6
7
+ data.tar.gz: a21ce4d54dc367e77db6db6695e48d1e9ce2ce96847513987be2bb7138a27cefa641c6cfa4b96945d62465e279b54a49097b6fb73b3c4448edca6053178c2740
data/Gemfile CHANGED
@@ -4,9 +4,11 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem 'webmock'
8
7
  gem 'minitest-reporters'
9
-
10
8
  # gem 'guard'
11
9
  # gem 'guard-minitest'
12
10
  end
11
+
12
+ group :development, :test do
13
+ gem 'webmock'
14
+ end
@@ -8,7 +8,7 @@ module Moyasar
8
8
  end
9
9
 
10
10
  module ClassMethods
11
- # TODO should accept pagination and query options
11
+ # TODO: should accept pagination and query options ..
12
12
  def list(attrs = {})
13
13
  response = request(:get, list_url, params: attrs)
14
14
  response.body[resource_name].map { |resource| new(resource) }
@@ -1,6 +1,16 @@
1
1
  module Moyasar
2
2
  class Invoice < Resource
3
- attr_reader :id, :status, :amount_format, :url, :created_at, :updated_at
3
+ attr_reader :id, :status, :amount_format, :url, :payments, :created_at, :updated_at
4
4
  attr_accessor :description, :amount, :currency
5
+
6
+ def ==(other)
7
+ return false unless other.is_a? Invoice
8
+
9
+ [:id, :status, :description, :amount, :currency, :url, :created_at, :updated_at].all? do |attr|
10
+ self.send(attr) == other.send(attr)
11
+ end
12
+ end
13
+
14
+ alias to_s inspect
5
15
  end
6
16
  end
@@ -14,12 +14,20 @@ module Moyasar
14
14
  super
15
15
  end
16
16
 
17
- # TODO == should work between payments
17
+ def ==(other)
18
+ return false unless other.is_a? Payment
19
+
20
+ [:id, :status, :amount, :fee, :currency, :invoice_id, :source, :refunded, :refunded_at, :ip, :created_at, :updated_at].all? do |attr|
21
+ self.send(attr) == other.send(attr)
22
+ end
23
+ end
24
+
25
+ alias to_s inspect
18
26
 
19
27
  class << self
20
28
 
21
- def create(source:, amount:, currency: 'SAR', description: nil)
22
- params = {amount: amount, currency: currency, description: description, source: source}
29
+ def create(source:, amount:, currency: 'SAR', description: nil, invoice_id: nil)
30
+ params = {amount: amount, currency: currency, description: description, source: source, invoice_id: invoice_id}
23
31
  super(params)
24
32
  end
25
33
 
@@ -1,5 +1,10 @@
1
1
  module Moyasar
2
2
  class CreditCard < Source
3
3
  attr_reader :company, :name, :number, :message
4
+
5
+ def ==(other)
6
+ return unless other.instance_of? CreditCard
7
+ [:company, :name, :number, :message].all? { |attr| self.send(attr) == other.send(attr) }
8
+ end
4
9
  end
5
10
  end
@@ -1,5 +1,10 @@
1
1
  module Moyasar
2
2
  class Sadad < Source
3
3
  attr_reader :username, :error_code, :message, :transaction_url, :transaction_id
4
+
5
+ def ==(other)
6
+ return unless other.instance_of? Sadad
7
+ [:username, :error_code, :message, :transaction_url, :transaction_id].all? { |attr| self.send(attr) == other.send(attr) }
8
+ end
4
9
  end
5
10
  end
@@ -1,3 +1,3 @@
1
1
  module Moyasar
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.4'
3
3
  end
data/lib/moyasar.rb CHANGED
@@ -57,10 +57,10 @@ module Moyasar
57
57
  case response.code
58
58
  when 400..429
59
59
  error_data = response.body.merge({ 'http_code' => response.code })
60
- error = Errors[response.body['type']].new(error_data)
61
- raise error
60
+ error = Errors[response.body['type']]
61
+ raise error, error_data
62
62
  when 500..504
63
- raise APIError.new({ 'http_code' => response.code })
63
+ raise APIError, { 'http_code' => response.code }
64
64
  end
65
65
  response
66
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moyasar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdulaziz AlShetwi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.5.1
117
+ rubygems_version: 2.6.11
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Ruby wrapper library for Moyasar Payment Service