mc2p-ruby 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/mc2p.rb +7 -0
- data/lib/mixins.rb +29 -0
- data/lib/notification.rb +5 -0
- data/lib/objects.rb +24 -1
- data/lib/resources.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f0cfa6c2169f6dbac06b31c219eb56791ba0c55
|
4
|
+
data.tar.gz: 2279b7d48666e646e1eba1a286b9c89e3757bc8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a82f82af7007cf7550f9e51f278cf6657a51c390154f4d345e699a3cf18fc7cd45e4ce2dc966341c6673fae8e0779a7e2ccde364fede852d3825a250dfc1e29
|
7
|
+
data.tar.gz: 13959aa02c0952a0ab21db9a77256ab78679583227a45f6e695bfe9e397463179ad047e3c1731e0a2d10a4e99d425544ceea443ea90afb81f05f710b0918c5e1
|
data/README.md
CHANGED
data/lib/mc2p.rb
CHANGED
@@ -56,6 +56,9 @@ module MC2P
|
|
56
56
|
@subscription_resource = SubscriptionResource.new(@api_request,
|
57
57
|
'/subscription/',
|
58
58
|
Subscription)
|
59
|
+
@authorization_resource = AuthorizationResource.new(@api_request,
|
60
|
+
'/authorization/',
|
61
|
+
Authorization)
|
59
62
|
@sale_resource = SaleResource.new(@api_request,
|
60
63
|
'/sale/',
|
61
64
|
Sale)
|
@@ -102,6 +105,10 @@ module MC2P
|
|
102
105
|
_wrapper(Subscription, @subscription_resource, data)
|
103
106
|
end
|
104
107
|
|
108
|
+
def authorization(data)
|
109
|
+
_wrapper(Authorization, @authorization_resource, data)
|
110
|
+
end
|
111
|
+
|
105
112
|
def sale(data)
|
106
113
|
_wrapper(Sale, @sale_resource, data)
|
107
114
|
end
|
data/lib/mixins.rb
CHANGED
@@ -156,6 +156,21 @@ module MC2P
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
# Allows make charge an object item
|
160
|
+
class ChargeObjectItemMixin < ObjectItemMixin
|
161
|
+
# Refund the object item
|
162
|
+
# Params:
|
163
|
+
# +data+:: data to send
|
164
|
+
# Returns: response dictionary
|
165
|
+
def charge(data = nil)
|
166
|
+
id_required_and_not_deleted
|
167
|
+
@resource.charge(
|
168
|
+
@json_dict[@id_property],
|
169
|
+
data
|
170
|
+
)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
159
174
|
# Add property to get pay_url based on token
|
160
175
|
class PayURLMixin < ObjectItemMixin
|
161
176
|
def initialize(json_dict, resource)
|
@@ -374,4 +389,18 @@ module MC2P
|
|
374
389
|
data)
|
375
390
|
end
|
376
391
|
end
|
392
|
+
|
393
|
+
# Allows send action requests of charge
|
394
|
+
class ChargeResourceMixin < ActionsResourceMixin
|
395
|
+
# Params:
|
396
|
+
# +resource_id+:: id to request
|
397
|
+
# +data+:: data to send
|
398
|
+
# Returns: response dictionary
|
399
|
+
def charge(resource_id, data = nil)
|
400
|
+
_one_item_action('post200',
|
401
|
+
resource_id,
|
402
|
+
'charge',
|
403
|
+
data)
|
404
|
+
end
|
405
|
+
end
|
377
406
|
end
|
data/lib/notification.rb
CHANGED
data/lib/objects.rb
CHANGED
@@ -31,11 +31,34 @@ module MC2P
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# Subscription object
|
34
|
-
|
35
34
|
class Subscription < PayURLCRObjectItem
|
36
35
|
|
37
36
|
end
|
38
37
|
|
38
|
+
# Authorization object
|
39
|
+
class Authorization < PayURLCRObjectItem
|
40
|
+
# Initializes an object item
|
41
|
+
# Params:
|
42
|
+
# +json_dict+:: Data of the object
|
43
|
+
# +resource+:: Resource used to delete, save, create or retrieve the object
|
44
|
+
def initialize(json_dict, resource)
|
45
|
+
super(json_dict, resource)
|
46
|
+
@charge_mixin = ChargeObjectItemMixin.new(json_dict, resource)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Charge the object item
|
50
|
+
# Params:
|
51
|
+
# +data+:: data to send
|
52
|
+
# Returns: response dictionary
|
53
|
+
def charge(data = nil)
|
54
|
+
@charge_mixin.json_dict = @json_dict
|
55
|
+
@charge_mixin._deleted = @_deleted
|
56
|
+
@charge_mixin.charge(data)
|
57
|
+
@json_dict = @charge_mixin.json_dict
|
58
|
+
@_deleted = @charge_mixin._deleted
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
39
62
|
# Sale object
|
40
63
|
class Sale < ReadOnlyObjectItem
|
41
64
|
# Initializes an object item
|
data/lib/resources.rb
CHANGED
@@ -27,6 +27,29 @@ module MC2P
|
|
27
27
|
class SubscriptionResource < CRResource
|
28
28
|
end
|
29
29
|
|
30
|
+
# Authorization resource
|
31
|
+
class AuthorizationResource < CRResource
|
32
|
+
# Initializes a resource
|
33
|
+
# Params:
|
34
|
+
# +api_request+:: Api request used to make all the requests to the API
|
35
|
+
# +path+:: Path used to make all the requests to the API
|
36
|
+
# +object_item_class+:: Object item class used to return values
|
37
|
+
def initialize(api_request, path, object_item_class)
|
38
|
+
super(api_request, path, object_item_class)
|
39
|
+
@charge_resource_mixin = ChargeResourceMixin.new(api_request, path,
|
40
|
+
object_item_class,
|
41
|
+
@paginator_class)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Params:
|
45
|
+
# +resource_id+:: id to request
|
46
|
+
# +data+:: data to send
|
47
|
+
# Returns: response dictionary
|
48
|
+
def charge(resource_id, data = nil)
|
49
|
+
@charge_resource_mixin.charge(resource_id, data)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
30
53
|
# Sale resource
|
31
54
|
class SaleResource < ReadOnlyResource
|
32
55
|
# Initializes a resource
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mc2p-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MyChoice2Pay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unirest
|