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 +4 -4
- data/Gemfile +4 -2
- data/lib/moyasar/actions/list.rb +1 -1
- data/lib/moyasar/invoice.rb +11 -1
- data/lib/moyasar/payment.rb +11 -3
- data/lib/moyasar/sources/credit_card.rb +5 -0
- data/lib/moyasar/sources/sadad.rb +5 -0
- data/lib/moyasar/version.rb +1 -1
- data/lib/moyasar.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9862490dc56ef2b68ff1ef2360b90a2b82d5b0d2
|
4
|
+
data.tar.gz: 4e2d39952fb39caca9081bad50c672e33af2ab17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e2681882484d94a8aa5ba8d958596e61166d5df21a17a32a96e0fcb92104b78b5cc5cf24049653758b6dafcfabde200b9fdfd1a0beef840fe0f0fd1ea2eb7a6
|
7
|
+
data.tar.gz: a21ce4d54dc367e77db6db6695e48d1e9ce2ce96847513987be2bb7138a27cefa641c6cfa4b96945d62465e279b54a49097b6fb73b3c4448edca6053178c2740
|
data/Gemfile
CHANGED
data/lib/moyasar/actions/list.rb
CHANGED
@@ -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) }
|
data/lib/moyasar/invoice.rb
CHANGED
@@ -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
|
data/lib/moyasar/payment.rb
CHANGED
@@ -14,12 +14,20 @@ module Moyasar
|
|
14
14
|
super
|
15
15
|
end
|
16
16
|
|
17
|
-
|
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
|
data/lib/moyasar/version.rb
CHANGED
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']]
|
61
|
-
raise error
|
60
|
+
error = Errors[response.body['type']]
|
61
|
+
raise error, error_data
|
62
62
|
when 500..504
|
63
|
-
raise APIError
|
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.
|
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-
|
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.
|
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
|