paypal-rest-api 0.0.2 → 0.0.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.
@@ -0,0 +1,213 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaypalAPI
4
+ #
5
+ # Manages subscriptions for recurring PayPal payments
6
+ #
7
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/
8
+ #
9
+ class Subscriptions < APICollection
10
+ #
11
+ # Common class and instance methods
12
+ #
13
+ module APIs
14
+ # @!macro [new] request
15
+ # @param query [Hash, nil] Request query parameters
16
+ # @param body [Hash, nil] Request body parameters
17
+ # @param headers [Hash, nil] Request headers
18
+ # @return [Response] Response object
19
+
20
+ #
21
+ # Creates a plan that defines pricing and billing cycle details for subscriptions.
22
+ #
23
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create
24
+ #
25
+ # @macro request
26
+ #
27
+ def create_plan(query: nil, body: nil, headers: nil)
28
+ client.post("/v1/billing/plans", query: query, body: body, headers: headers)
29
+ end
30
+
31
+ #
32
+ # List plans
33
+ #
34
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#plans_list
35
+ #
36
+ # @macro request
37
+ #
38
+ def list_plans(query: nil, body: nil, headers: nil)
39
+ client.get("/v1/billing/plans", query: query, body: body, headers: headers)
40
+ end
41
+
42
+ #
43
+ # Show plan details
44
+ #
45
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#plans_get
46
+ #
47
+ # @param plan_id [String] Plan ID
48
+ # @macro request
49
+ #
50
+ def show_plan(plan_id, query: nil, body: nil, headers: nil)
51
+ client.get("/v1/billing/plans/#{plan_id}", query: query, body: body, headers: headers)
52
+ end
53
+
54
+ #
55
+ # Update plan
56
+ #
57
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#plans_patch
58
+ #
59
+ # @param plan_id [String] Plan ID
60
+ # @macro request
61
+ #
62
+ def update_plan(plan_id, query: nil, body: nil, headers: nil)
63
+ client.patch("/v1/billing/plans/#{plan_id}", query: query, body: body, headers: headers)
64
+ end
65
+
66
+ #
67
+ # Activate plan
68
+ #
69
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#plans_activate
70
+ #
71
+ # @param plan_id [String] Plan ID
72
+ # @macro request
73
+ #
74
+ def activate_plan(plan_id, query: nil, body: nil, headers: nil)
75
+ client.post("/v1/billing/plans/#{plan_id}/activate", query: query, body: body, headers: headers)
76
+ end
77
+
78
+ #
79
+ # Deactivate plan
80
+ #
81
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#plans_deactivate
82
+ #
83
+ # @param plan_id [String] Plan ID
84
+ # @macro request
85
+ #
86
+ def deactivate_plan(plan_id, query: nil, body: nil, headers: nil)
87
+ client.post("/v1/billing/plans/#{plan_id}/deactivate", query: query, body: body, headers: headers)
88
+ end
89
+
90
+ #
91
+ # Update pricing
92
+ #
93
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#plans_deactivate
94
+ #
95
+ # @param plan_id [String] Plan ID
96
+ # @macro request
97
+ #
98
+ def update_plan_pricing(plan_id, query: nil, body: nil, headers: nil)
99
+ client.post("/v1/billing/plans/#{plan_id}/update-pricing-schemes", query: query, body: body, headers: headers)
100
+ end
101
+
102
+ #
103
+ # Create subscription
104
+ #
105
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create
106
+ #
107
+ # @macro request
108
+ #
109
+ def create_subscription(query: nil, body: nil, headers: nil)
110
+ client.post("/v1/billing/subscriptions", query: query, body: body, headers: headers)
111
+ end
112
+
113
+ #
114
+ # Show subscription details
115
+ #
116
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get
117
+ #
118
+ # @param subscription_id [String] Subscripton ID
119
+ # @macro request
120
+ #
121
+ def show_subscription(subscription_id, query: nil, body: nil, headers: nil)
122
+ client.get("/v1/billing/subscriptions/#{subscription_id}", query: query, body: body, headers: headers)
123
+ end
124
+
125
+ #
126
+ # Update subscription
127
+ #
128
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_patch
129
+ #
130
+ # @param subscription_id [String] Subscripton ID
131
+ # @macro request
132
+ #
133
+ def update_subscription(subscription_id, query: nil, body: nil, headers: nil)
134
+ client.patch("/v1/billing/subscriptions/#{subscription_id}", query: query, body: body, headers: headers)
135
+ end
136
+
137
+ #
138
+ # Revise plan or quantity of subscription
139
+ #
140
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_revise
141
+ #
142
+ # @param subscription_id [String] Subscripton ID
143
+ # @macro request
144
+ #
145
+ def revise_subscription(subscription_id, query: nil, body: nil, headers: nil)
146
+ client.post("/v1/billing/subscriptions/#{subscription_id}/revise", query: query, body: body, headers: headers)
147
+ end
148
+
149
+ #
150
+ # Suspend subscription
151
+ #
152
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_suspend
153
+ #
154
+ # @param subscription_id [String] Subscripton ID
155
+ # @macro request
156
+ #
157
+ def suspend_subscription(subscription_id, query: nil, body: nil, headers: nil)
158
+ client.post("/v1/billing/subscriptions/#{subscription_id}/suspend", query: query, body: body, headers: headers)
159
+ end
160
+
161
+ #
162
+ # Cancel subscription
163
+ #
164
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel
165
+ #
166
+ # @param subscription_id [String] Subscripton ID
167
+ # @macro request
168
+ #
169
+ def cancel_subscription(subscription_id, query: nil, body: nil, headers: nil)
170
+ client.post("/v1/billing/subscriptions/#{subscription_id}/cancel", query: query, body: body, headers: headers)
171
+ end
172
+
173
+ #
174
+ # Activate subscription
175
+ #
176
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_activate
177
+ #
178
+ # @param subscription_id [String] Subscripton ID
179
+ # @macro request
180
+ #
181
+ def activate_subscription(subscription_id, query: nil, body: nil, headers: nil)
182
+ client.post("/v1/billing/subscriptions/#{subscription_id}/activate", query: query, body: body, headers: headers)
183
+ end
184
+
185
+ #
186
+ # Capture authorized payment on subscription
187
+ #
188
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_capture
189
+ #
190
+ # @param subscription_id [String] Subscripton ID
191
+ # @macro request
192
+ #
193
+ def capture_subscription(subscription_id, query: nil, body: nil, headers: nil)
194
+ client.post("/v1/billing/subscriptions/#{subscription_id}/capture", query: query, body: body, headers: headers)
195
+ end
196
+
197
+ #
198
+ # List transactions for subscription
199
+ #
200
+ # @see https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions
201
+ #
202
+ # @param subscription_id [String] Subscripton ID
203
+ # @macro request
204
+ #
205
+ def transactions(subscription_id, query: nil, body: nil, headers: nil)
206
+ client.get("/v1/billing/subscriptions/#{subscription_id}/transactions", query: query, body: body, headers: headers)
207
+ end
208
+ end
209
+
210
+ include APIs
211
+ extend APIs
212
+ end
213
+ end
@@ -0,0 +1,206 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaypalAPI
4
+ #
5
+ # https://developer.paypal.com/docs/api/webhooks/v1/
6
+ #
7
+ class Webhooks < APICollection
8
+ #
9
+ # Common class and instance methods
10
+ #
11
+ module APIs
12
+ # @!macro [new] request
13
+ # @param query [Hash, nil] Request query parameters
14
+ # @param body [Hash, nil] Request body parameters
15
+ # @param headers [Hash, nil] Request headers
16
+ # @return [Response] Response object
17
+
18
+ #
19
+ # Create webhook
20
+ #
21
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_post
22
+ #
23
+ # @macro request
24
+ #
25
+ def create(query: nil, body: nil, headers: nil)
26
+ client.post("/v1/notifications/webhooks", query: query, body: body, headers: headers)
27
+ end
28
+
29
+ #
30
+ # List webhooks
31
+ #
32
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_list
33
+ #
34
+ # @macro request
35
+ #
36
+ def list(query: nil, body: nil, headers: nil)
37
+ client.get("/v1/notifications/webhooks", query: query, body: body, headers: headers)
38
+ end
39
+
40
+ #
41
+ # Show webhook details
42
+ #
43
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_get
44
+ #
45
+ # @param webhook_id [String] Webhook ID
46
+ # @macro request
47
+ #
48
+ def show(webhook_id, query: nil, body: nil, headers: nil)
49
+ client.get("/v1/notifications/webhooks/#{webhook_id}", query: query, body: body, headers: headers)
50
+ end
51
+
52
+ #
53
+ # Update webhook
54
+ #
55
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_update
56
+ #
57
+ # @param webhook_id [String] Webhook ID
58
+ # @macro request
59
+ #
60
+ def update(webhook_id, query: nil, body: nil, headers: nil)
61
+ client.patch("/v1/notifications/webhooks/#{webhook_id}", query: query, body: body, headers: headers)
62
+ end
63
+
64
+ #
65
+ # Delete webhook
66
+ #
67
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_delete
68
+ #
69
+ # @param webhook_id [String] Webhook ID
70
+ # @macro request
71
+ #
72
+ def delete(webhook_id, query: nil, body: nil, headers: nil)
73
+ client.delete("/v1/notifications/webhooks/#{webhook_id}", query: query, body: body, headers: headers)
74
+ end
75
+
76
+ #
77
+ # List event subscriptions for webhook
78
+ #
79
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#event-types_list
80
+ #
81
+ # @param webhook_id [String] Webhook ID
82
+ # @macro request
83
+ #
84
+ def list_event_types(webhook_id, query: nil, body: nil, headers: nil)
85
+ client.get("/v1/notifications/webhooks/#{webhook_id}/event-types", query: query, body: body, headers: headers)
86
+ end
87
+
88
+ #
89
+ # Create webhook lookup
90
+ #
91
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_post
92
+ #
93
+ # @macro request
94
+ #
95
+ def create_lookup(query: nil, body: nil, headers: nil)
96
+ client.post("/v1/notifications/webhooks-lookup", query: query, body: body, headers: headers)
97
+ end
98
+
99
+ #
100
+ # List webhook lookups
101
+ #
102
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_list
103
+ #
104
+ # @macro request
105
+ #
106
+ def list_lookups(query: nil, body: nil, headers: nil)
107
+ client.get("/v1/notifications/webhooks-lookup", query: query, body: body, headers: headers)
108
+ end
109
+
110
+ #
111
+ # Show webhook lookup details
112
+ #
113
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_get
114
+ #
115
+ # @param webhook_lookup_id [String] Webhook lookup ID
116
+ # @macro request
117
+ #
118
+ def show_lookup(webhook_lookup_id, query: nil, body: nil, headers: nil)
119
+ client.get("/v1/notifications/webhooks-lookup/#{webhook_lookup_id}", query: query, body: body, headers: headers)
120
+ end
121
+
122
+ #
123
+ # Delete webhook lookup
124
+ #
125
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_delete
126
+ #
127
+ # @param webhook_lookup_id [String] Webhook lookup ID
128
+ # @macro request
129
+ #
130
+ def delete_lookup(webhook_lookup_id, query: nil, body: nil, headers: nil)
131
+ client.delete("/v1/notifications/webhooks-lookup/#{webhook_lookup_id}", query: query, body: body, headers: headers)
132
+ end
133
+
134
+ #
135
+ # Verify webhook signature
136
+ #
137
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#verify-webhook-signature_post
138
+ #
139
+ # @macro request
140
+ #
141
+ def verify(query: nil, body: nil, headers: nil)
142
+ client.post("/v1/notifications/verify-webhook-signature", query: query, body: body, headers: headers)
143
+ end
144
+
145
+ #
146
+ # Lists available events to which any webhook can subscribe
147
+ #
148
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-event-types_list
149
+ #
150
+ # @macro request
151
+ #
152
+ def list_available_events(query: nil, body: nil, headers: nil)
153
+ client.get("/v1/notifications/webhooks-event-types", query: query, body: body, headers: headers)
154
+ end
155
+
156
+ #
157
+ # List event notifications
158
+ #
159
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_list
160
+ #
161
+ # @macro request
162
+ #
163
+ def list_events(query: nil, body: nil, headers: nil)
164
+ client.get("/v1/notifications/webhooks-events", query: query, body: body, headers: headers)
165
+ end
166
+
167
+ #
168
+ # Show event notification details
169
+ #
170
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_get
171
+ #
172
+ # @param event_id [String] Event ID
173
+ # @macro request
174
+ #
175
+ def show_event(event_id, query: nil, body: nil, headers: nil)
176
+ client.get("/v1/notifications/webhooks-events/#{event_id}", query: query, body: body, headers: headers)
177
+ end
178
+
179
+ #
180
+ # Resend event notification
181
+ #
182
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_resend
183
+ #
184
+ # @param event_id [String] Event ID
185
+ # @macro request
186
+ #
187
+ def resend_event(event_id, query: nil, body: nil, headers: nil)
188
+ client.post("/v1/notifications/webhooks-events/#{event_id}/resend", query: query, body: body, headers: headers)
189
+ end
190
+
191
+ #
192
+ # Simulate webhook event
193
+ #
194
+ # @see https://developer.paypal.com/docs/api/webhooks/v1/#simulate-event_post
195
+ #
196
+ # @macro request
197
+ #
198
+ def simulate_event(query: nil, body: nil, headers: nil)
199
+ client.post("/v1/notifications/simulate-event", query: query, body: body, headers: headers)
200
+ end
201
+ end
202
+
203
+ include APIs
204
+ extend APIs
205
+ end
206
+ end
@@ -54,15 +54,18 @@ module PaypalAPI
54
54
  )
55
55
  end
56
56
 
57
- #
58
- # Executes POST http request
59
- #
57
+ # @!macro [new] request
60
58
  # @param path [String] Request path
61
59
  # @param query [Hash, nil] Request query parameters
62
60
  # @param body [Hash, nil] Request body parameters
63
61
  # @param headers [Hash, nil] Request headers
64
62
  #
65
63
  # @return [Response] Response object
64
+
65
+ #
66
+ # Executes POST http request
67
+ #
68
+ # @macro request
66
69
  #
67
70
  def post(path, query: nil, body: nil, headers: nil)
68
71
  execute_request(Net::HTTP::Post, path, query: query, body: body, headers: headers)
@@ -71,12 +74,7 @@ module PaypalAPI
71
74
  #
72
75
  # Executes GET http request
73
76
  #
74
- # @param path [String] Request path
75
- # @param query [Hash, nil] Request query parameters
76
- # @param body [Hash, nil] Request body parameters
77
- # @param headers [Hash, nil] Request headers
78
- #
79
- # @return [Response] Response object
77
+ # @macro request
80
78
  #
81
79
  def get(path, query: nil, body: nil, headers: nil)
82
80
  execute_request(Net::HTTP::Get, path, query: query, body: body, headers: headers)
@@ -85,12 +83,7 @@ module PaypalAPI
85
83
  #
86
84
  # Executes PATCH http request
87
85
  #
88
- # @param path [String] Request path
89
- # @param query [Hash, nil] Request query parameters
90
- # @param body [Hash, nil] Request body parameters
91
- # @param headers [Hash, nil] Request headers
92
- #
93
- # @return [Response] Response object
86
+ # @macro request
94
87
  #
95
88
  def patch(path, query: nil, body: nil, headers: nil)
96
89
  execute_request(Net::HTTP::Patch, path, query: query, body: body, headers: headers)
@@ -99,12 +92,7 @@ module PaypalAPI
99
92
  #
100
93
  # Executes PUT http request
101
94
  #
102
- # @param path [String] Request path
103
- # @param query [Hash, nil] Request query parameters
104
- # @param body [Hash, nil] Request body parameters
105
- # @param headers [Hash, nil] Request headers
106
- #
107
- # @return [Response] Response object
95
+ # @macro request
108
96
  #
109
97
  def put(path, query: nil, body: nil, headers: nil)
110
98
  execute_request(Net::HTTP::Put, path, query: query, body: body, headers: headers)
@@ -113,30 +101,50 @@ module PaypalAPI
113
101
  #
114
102
  # Executes DELETE http request
115
103
  #
116
- # @param path [String] Request path
117
- # @param query [Hash, nil] Request query parameters
118
- # @param body [Hash, nil] Request body parameters
119
- # @param headers [Hash, nil] Request headers
120
- #
121
- # @return [Response] Response object
104
+ # @macro request
122
105
  #
123
106
  def delete(path, query: nil, body: nil, headers: nil)
124
107
  execute_request(Net::HTTP::Delete, path, query: query, body: body, headers: headers)
125
108
  end
126
109
 
110
+ # @return [AuthorizedPayments] AuthorizedPayments APIs collection
111
+ def authorized_payments
112
+ AuthorizedPayments.new(self)
113
+ end
114
+
115
+ # @return [CapturedPayments] CapturedPayments APIs collection
116
+ def captured_payments
117
+ CapturedPayments.new(self)
118
+ end
119
+
127
120
  # @return [Authentication] Authentication APIs collection
128
121
  def authentication
129
122
  Authentication.new(self)
130
123
  end
131
124
 
125
+ # @return [CatalogProducts] Catalog Products APIs collection
126
+ def catalog_products
127
+ CatalogProducts.new(self)
128
+ end
129
+
132
130
  # @return [Orders] Orders APIs collection
133
131
  def orders
134
132
  Orders.new(self)
135
133
  end
136
134
 
137
- # @return [Payments] Payments APIs collection
138
- def payments
139
- Payments.new(self)
135
+ # @return [Redunds] Refunds APIs collection
136
+ def refunds
137
+ Refunds.new(self)
138
+ end
139
+
140
+ # @return [ShipmentTracking] Shipment Tracking APIs collection
141
+ def shipment_tracking
142
+ ShipmentTracking.new(self)
143
+ end
144
+
145
+ # @return [Subscriptions] Subscriptions APIs collection
146
+ def subscriptions
147
+ Subscriptions.new(self)
140
148
  end
141
149
 
142
150
  # @return [Webhooks] Webhooks APIs collection