mc2p-ruby 0.1.2 → 0.1.3

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: 2cf6d964ae739ae4de6ac141e488f89a29b28122
4
- data.tar.gz: '0590e374daf4ad713f50b31d0880ab9f5b44d3d2'
3
+ metadata.gz: 8f0cfa6c2169f6dbac06b31c219eb56791ba0c55
4
+ data.tar.gz: 2279b7d48666e646e1eba1a286b9c89e3757bc8c
5
5
  SHA512:
6
- metadata.gz: 2f265ef00b103392dcd85527a53b368fccfbf48722547892aa2c50d717883a2b89cd2a1c0392b598c4556a9c5a2b6e644ebe3740522c38b17890d737ab22246c
7
- data.tar.gz: 4003ad34dca603880af5be7a7e7ea333483e904f2053604d242ffaa2830a4a82414ca4d38ae7cdc5e389f037b3dff6f178ad12f6c562667e8f96b174da0fe90c
6
+ metadata.gz: 0a82f82af7007cf7550f9e51f278cf6657a51c390154f4d345e699a3cf18fc7cd45e4ce2dc966341c6673fae8e0779a7e2ccde364fede852d3825a250dfc1e29
7
+ data.tar.gz: 13959aa02c0952a0ab21db9a77256ab78679583227a45f6e695bfe9e397463179ad047e3c1731e0a2d10a4e99d425544ceea443ea90afb81f05f710b0918c5e1
data/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  MyChoice2Pay Ruby provides integration access to the MyChoice2Pay API.
7
7
 
8
+ [![Build Status](https://travis-ci.org/mc2p/mc2p-ruby.svg?branch=master)](https://travis-ci.org/mc2p/mc2p-ruby)
9
+
8
10
  # Installation
9
11
 
10
12
  Add this line to your application's Gemfile:
@@ -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
@@ -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
@@ -20,6 +20,11 @@ module MC2P
20
20
  @json_body['subscription_status']
21
21
  end
22
22
 
23
+ # Returns: status of authorization
24
+ def authorization_status
25
+ @json_body['authorization_status']
26
+ end
27
+
23
28
  # Returns: type of payment
24
29
  def type
25
30
  @json_body['type']
@@ -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
@@ -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.2
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-09-18 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unirest