paypal-rest-api 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +320 -44
- data/VERSION +1 -1
- data/lib/paypal-api/access_token.rb +16 -2
- data/lib/paypal-api/api_collection.rb +29 -0
- data/lib/paypal-api/api_collections/authorized_payments.rb +4 -4
- data/lib/paypal-api/api_collections/captured_payments.rb +2 -2
- data/lib/paypal-api/api_collections/catalog_products.rb +2 -2
- data/lib/paypal-api/api_collections/disputes.rb +188 -0
- data/lib/paypal-api/api_collections/invoice_templates.rb +82 -0
- data/lib/paypal-api/api_collections/invoices.rb +196 -0
- data/lib/paypal-api/api_collections/orders.rb +7 -7
- data/lib/paypal-api/api_collections/payout_items.rb +47 -0
- data/lib/paypal-api/api_collections/payouts.rb +47 -0
- data/lib/paypal-api/api_collections/referenced_payout_items.rb +47 -0
- data/lib/paypal-api/api_collections/referenced_payouts.rb +47 -0
- data/lib/paypal-api/api_collections/refunds.rb +1 -1
- data/lib/paypal-api/api_collections/shipment_tracking.rb +2 -2
- data/lib/paypal-api/api_collections/subscription_plans.rb +106 -0
- data/lib/paypal-api/api_collections/subscriptions.rb +16 -98
- data/lib/paypal-api/api_collections/user_info.rb +47 -0
- data/lib/paypal-api/api_collections/users.rb +96 -0
- data/lib/paypal-api/api_collections/webhook_events.rb +78 -0
- data/lib/paypal-api/api_collections/webhook_lookups.rb +68 -0
- data/lib/paypal-api/api_collections/webhooks.rb +5 -108
- data/lib/paypal-api/client.rb +129 -5
- data/lib/paypal-api/config.rb +6 -2
- data/lib/paypal-api/request.rb +53 -21
- data/lib/paypal-api/request_executor.rb +81 -66
- data/lib/paypal-api/response.rb +42 -5
- data/lib/paypal-api/webhook_verifier/certs_cache.rb +75 -0
- data/lib/paypal-api/webhook_verifier.rb +104 -0
- data/lib/paypal-api.rb +120 -12
- metadata +17 -3
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaypalAPI
|
4
|
+
#
|
5
|
+
# The Referenced Payouts API enables partner merchants and developers to process individual referenced payouts to recipients.
|
6
|
+
#
|
7
|
+
# @see https://developer.paypal.com/docs/api/referenced-payouts/v1/
|
8
|
+
#
|
9
|
+
class ReferencedPayouts < 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
|
+
# Create referenced batch payout
|
22
|
+
#
|
23
|
+
# @see https://developer.paypal.com/docs/api/referenced-payouts/v1/#referenced-payouts_create_batch
|
24
|
+
#
|
25
|
+
# @macro request
|
26
|
+
#
|
27
|
+
def create(query: nil, body: nil, headers: nil)
|
28
|
+
client.post("/v1/payments/referenced-payouts", query: query, body: body, headers: headers)
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# List items in referenced batch payout
|
33
|
+
#
|
34
|
+
# @see https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts_get
|
35
|
+
#
|
36
|
+
# @param payout_batch_id [String] The ID of the reference batch payout for which to list items.
|
37
|
+
# @macro request
|
38
|
+
#
|
39
|
+
def show(payout_batch_id, query: nil, body: nil, headers: nil)
|
40
|
+
client.get("/v1/payments/referenced-payouts/#{encode(payout_batch_id)}", query: query, body: body, headers: headers)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
include APIs
|
45
|
+
extend APIs
|
46
|
+
end
|
47
|
+
end
|
@@ -20,7 +20,7 @@ module PaypalAPI
|
|
20
20
|
# @macro request
|
21
21
|
#
|
22
22
|
def show(refund_id, query: nil, body: nil, headers: nil)
|
23
|
-
client.get("/v2/payments/refunds/#{refund_id}", query: query, body: body, headers: headers)
|
23
|
+
client.get("/v2/payments/refunds/#{encode(refund_id)}", query: query, body: body, headers: headers)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -37,7 +37,7 @@ module PaypalAPI
|
|
37
37
|
# @macro request
|
38
38
|
#
|
39
39
|
def update(id, query: nil, body: nil, headers: nil)
|
40
|
-
client.put("/v1/shipping/trackers/#{id}", query: query, body: body, headers: headers)
|
40
|
+
client.put("/v1/shipping/trackers/#{encode(id)}", query: query, body: body, headers: headers)
|
41
41
|
end
|
42
42
|
|
43
43
|
#
|
@@ -49,7 +49,7 @@ module PaypalAPI
|
|
49
49
|
# @macro request
|
50
50
|
#
|
51
51
|
def show(id, query: nil, body: nil, headers: nil)
|
52
|
-
client.get("/v1/shipping/trackers/#{id}", query: query, body: body, headers: headers)
|
52
|
+
client.get("/v1/shipping/trackers/#{encode(id)}", query: query, body: body, headers: headers)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -0,0 +1,106 @@
|
|
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 SubscriptionPlans < 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(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(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_id, query: nil, body: nil, headers: nil)
|
51
|
+
client.get("/v1/billing/plans/#{encode(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_id, query: nil, body: nil, headers: nil)
|
63
|
+
client.patch("/v1/billing/plans/#{encode(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_id, query: nil, body: nil, headers: nil)
|
75
|
+
client.post("/v1/billing/plans/#{encode(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_id, query: nil, body: nil, headers: nil)
|
87
|
+
client.post("/v1/billing/plans/#{encode(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_pricing(plan_id, query: nil, body: nil, headers: nil)
|
99
|
+
client.post("/v1/billing/plans/#{encode(plan_id)}/update-pricing-schemes", query: query, body: body, headers: headers)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
include APIs
|
104
|
+
extend APIs
|
105
|
+
end
|
106
|
+
end
|
@@ -17,88 +17,6 @@ module PaypalAPI
|
|
17
17
|
# @param headers [Hash, nil] Request headers
|
18
18
|
# @return [Response] Response object
|
19
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
20
|
#
|
103
21
|
# Create subscription
|
104
22
|
#
|
@@ -106,7 +24,7 @@ module PaypalAPI
|
|
106
24
|
#
|
107
25
|
# @macro request
|
108
26
|
#
|
109
|
-
def
|
27
|
+
def create(query: nil, body: nil, headers: nil)
|
110
28
|
client.post("/v1/billing/subscriptions", query: query, body: body, headers: headers)
|
111
29
|
end
|
112
30
|
|
@@ -118,8 +36,8 @@ module PaypalAPI
|
|
118
36
|
# @param subscription_id [String] Subscripton ID
|
119
37
|
# @macro request
|
120
38
|
#
|
121
|
-
def
|
122
|
-
client.get("/v1/billing/subscriptions/#{subscription_id}", query: query, body: body, headers: headers)
|
39
|
+
def show(subscription_id, query: nil, body: nil, headers: nil)
|
40
|
+
client.get("/v1/billing/subscriptions/#{encode(subscription_id)}", query: query, body: body, headers: headers)
|
123
41
|
end
|
124
42
|
|
125
43
|
#
|
@@ -130,8 +48,8 @@ module PaypalAPI
|
|
130
48
|
# @param subscription_id [String] Subscripton ID
|
131
49
|
# @macro request
|
132
50
|
#
|
133
|
-
def
|
134
|
-
client.patch("/v1/billing/subscriptions/#{subscription_id}", query: query, body: body, headers: headers)
|
51
|
+
def update(subscription_id, query: nil, body: nil, headers: nil)
|
52
|
+
client.patch("/v1/billing/subscriptions/#{encode(subscription_id)}", query: query, body: body, headers: headers)
|
135
53
|
end
|
136
54
|
|
137
55
|
#
|
@@ -142,8 +60,8 @@ module PaypalAPI
|
|
142
60
|
# @param subscription_id [String] Subscripton ID
|
143
61
|
# @macro request
|
144
62
|
#
|
145
|
-
def
|
146
|
-
client.post("/v1/billing/subscriptions/#{subscription_id}/revise", query: query, body: body, headers: headers)
|
63
|
+
def revise(subscription_id, query: nil, body: nil, headers: nil)
|
64
|
+
client.post("/v1/billing/subscriptions/#{encode(subscription_id)}/revise", query: query, body: body, headers: headers)
|
147
65
|
end
|
148
66
|
|
149
67
|
#
|
@@ -154,8 +72,8 @@ module PaypalAPI
|
|
154
72
|
# @param subscription_id [String] Subscripton ID
|
155
73
|
# @macro request
|
156
74
|
#
|
157
|
-
def
|
158
|
-
client.post("/v1/billing/subscriptions/#{subscription_id}/suspend", query: query, body: body, headers: headers)
|
75
|
+
def suspend(subscription_id, query: nil, body: nil, headers: nil)
|
76
|
+
client.post("/v1/billing/subscriptions/#{encode(subscription_id)}/suspend", query: query, body: body, headers: headers)
|
159
77
|
end
|
160
78
|
|
161
79
|
#
|
@@ -166,8 +84,8 @@ module PaypalAPI
|
|
166
84
|
# @param subscription_id [String] Subscripton ID
|
167
85
|
# @macro request
|
168
86
|
#
|
169
|
-
def
|
170
|
-
client.post("/v1/billing/subscriptions/#{subscription_id}/cancel", query: query, body: body, headers: headers)
|
87
|
+
def cancel(subscription_id, query: nil, body: nil, headers: nil)
|
88
|
+
client.post("/v1/billing/subscriptions/#{encode(subscription_id)}/cancel", query: query, body: body, headers: headers)
|
171
89
|
end
|
172
90
|
|
173
91
|
#
|
@@ -178,8 +96,8 @@ module PaypalAPI
|
|
178
96
|
# @param subscription_id [String] Subscripton ID
|
179
97
|
# @macro request
|
180
98
|
#
|
181
|
-
def
|
182
|
-
client.post("/v1/billing/subscriptions/#{subscription_id}/activate", query: query, body: body, headers: headers)
|
99
|
+
def activate(subscription_id, query: nil, body: nil, headers: nil)
|
100
|
+
client.post("/v1/billing/subscriptions/#{encode(subscription_id)}/activate", query: query, body: body, headers: headers)
|
183
101
|
end
|
184
102
|
|
185
103
|
#
|
@@ -190,8 +108,8 @@ module PaypalAPI
|
|
190
108
|
# @param subscription_id [String] Subscripton ID
|
191
109
|
# @macro request
|
192
110
|
#
|
193
|
-
def
|
194
|
-
client.post("/v1/billing/subscriptions/#{subscription_id}/capture", query: query, body: body, headers: headers)
|
111
|
+
def capture(subscription_id, query: nil, body: nil, headers: nil)
|
112
|
+
client.post("/v1/billing/subscriptions/#{encode(subscription_id)}/capture", query: query, body: body, headers: headers)
|
195
113
|
end
|
196
114
|
|
197
115
|
#
|
@@ -203,7 +121,7 @@ module PaypalAPI
|
|
203
121
|
# @macro request
|
204
122
|
#
|
205
123
|
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)
|
124
|
+
client.get("/v1/billing/subscriptions/#{encode(subscription_id)}/transactions", query: query, body: body, headers: headers)
|
207
125
|
end
|
208
126
|
end
|
209
127
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaypalAPI
|
4
|
+
#
|
5
|
+
# Shows OpenID Connect user profile information
|
6
|
+
#
|
7
|
+
# @see https://developer.paypal.com/docs/api/identity/v1/
|
8
|
+
#
|
9
|
+
class UserInfo < APICollection
|
10
|
+
#
|
11
|
+
# Common class and instance methods
|
12
|
+
#
|
13
|
+
module APIs
|
14
|
+
# @!macro [new] request
|
15
|
+
|
16
|
+
#
|
17
|
+
# Show user profile details
|
18
|
+
#
|
19
|
+
# @see https://developer.paypal.com/docs/api/identity/v1/#userinfo_get
|
20
|
+
#
|
21
|
+
# @param query [Hash, nil] Request query parameters
|
22
|
+
# @param body [Hash, nil] Request body parameters
|
23
|
+
# @param headers [Hash, nil] Request headers
|
24
|
+
# @return [Response] Response object
|
25
|
+
#
|
26
|
+
def show(query: nil, body: nil, headers: nil)
|
27
|
+
query = add_schema_param(query)
|
28
|
+
|
29
|
+
client.get("/v1/identity/openidconnect/userinfo", query: query, body: body, headers: headers)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def add_schema_param(query)
|
35
|
+
return query if query.is_a?(Hash) && (query.key?(:schema) || query.key?("schema"))
|
36
|
+
|
37
|
+
defaults = {schema: "openid"}
|
38
|
+
return defaults unless query
|
39
|
+
|
40
|
+
query.merge(defaults)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
include APIs
|
45
|
+
extend APIs
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaypalAPI
|
4
|
+
#
|
5
|
+
# Managing users APIs
|
6
|
+
#
|
7
|
+
# https://developer.paypal.com/docs/api/identity/v2/
|
8
|
+
#
|
9
|
+
class Users < 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
|
+
# Create user
|
22
|
+
#
|
23
|
+
# @see https://developer.paypal.com/docs/api/identity/v2/#users_create
|
24
|
+
#
|
25
|
+
# @macro request
|
26
|
+
#
|
27
|
+
def create(query: nil, body: nil, headers: nil)
|
28
|
+
headers = add_scim_content_type(headers)
|
29
|
+
client.post("/v2/scim/Users", query: query, body: body, headers: headers)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# List users
|
34
|
+
#
|
35
|
+
# @see https://developer.paypal.com/docs/api/identity/v2/#users_list
|
36
|
+
#
|
37
|
+
# @macro request
|
38
|
+
#
|
39
|
+
def list(query: nil, body: nil, headers: nil)
|
40
|
+
headers = add_scim_content_type(headers)
|
41
|
+
client.get("/v2/scim/Users", query: query, body: body, headers: headers)
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Show user details
|
46
|
+
#
|
47
|
+
# @see https://developer.paypal.com/docs/api/identity/v2/#users_get
|
48
|
+
#
|
49
|
+
# @param user_id [String] User ID
|
50
|
+
# @macro request
|
51
|
+
#
|
52
|
+
def show(user_id, query: nil, body: nil, headers: nil)
|
53
|
+
headers = add_scim_content_type(headers)
|
54
|
+
client.get("/v2/scim/Users/#{encode(user_id)}", query: query, body: body, headers: headers)
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Update user
|
59
|
+
#
|
60
|
+
# @see https://developer.paypal.com/docs/api/identity/v2/#users_update
|
61
|
+
#
|
62
|
+
# @param user_id [String] User ID
|
63
|
+
# @macro request
|
64
|
+
#
|
65
|
+
def update(user_id, query: nil, body: nil, headers: nil)
|
66
|
+
headers = add_scim_content_type(headers)
|
67
|
+
client.patch("/v2/scim/Users/#{encode(user_id)}", query: query, body: body, headers: headers)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Delete user
|
72
|
+
#
|
73
|
+
# @see https://developer.paypal.com/docs/api/identity/v2/#users_delete
|
74
|
+
#
|
75
|
+
# @param user_id [String] User ID
|
76
|
+
# @macro request
|
77
|
+
#
|
78
|
+
def delete(user_id, query: nil, body: nil, headers: nil)
|
79
|
+
headers = add_scim_content_type(headers)
|
80
|
+
client.delete("/v2/scim/Users/#{encode(user_id)}", query: query, body: body, headers: headers)
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def add_scim_content_type(headers)
|
86
|
+
headers ||= {}
|
87
|
+
headers = headers.transform_keys { |key| (key.to_s.downcase == "content-type") ? "content-type" : key }
|
88
|
+
headers["content-type"] ||= "application/scim+json"
|
89
|
+
headers
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
include APIs
|
94
|
+
extend APIs
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaypalAPI
|
4
|
+
#
|
5
|
+
# https://developer.paypal.com/docs/api/webhooks/v1/
|
6
|
+
#
|
7
|
+
class WebhookEvents < 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
|
+
# Lists available events to which any webhook can subscribe
|
19
|
+
#
|
20
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-event-types_list
|
21
|
+
#
|
22
|
+
# @macro request
|
23
|
+
#
|
24
|
+
def available(query: nil, body: nil, headers: nil)
|
25
|
+
client.get("/v1/notifications/webhooks-event-types", query: query, body: body, headers: headers)
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# List event notifications
|
30
|
+
#
|
31
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_list
|
32
|
+
#
|
33
|
+
# @macro request
|
34
|
+
#
|
35
|
+
def list(query: nil, body: nil, headers: nil)
|
36
|
+
client.get("/v1/notifications/webhooks-events", query: query, body: body, headers: headers)
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Show event notification details
|
41
|
+
#
|
42
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_get
|
43
|
+
#
|
44
|
+
# @param event_id [String] Event ID
|
45
|
+
# @macro request
|
46
|
+
#
|
47
|
+
def show(event_id, query: nil, body: nil, headers: nil)
|
48
|
+
client.get("/v1/notifications/webhooks-events/#{encode(event_id)}", query: query, body: body, headers: headers)
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Resend event notification
|
53
|
+
#
|
54
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-events_resend
|
55
|
+
#
|
56
|
+
# @param event_id [String] Event ID
|
57
|
+
# @macro request
|
58
|
+
#
|
59
|
+
def resend(event_id, query: nil, body: nil, headers: nil)
|
60
|
+
client.post("/v1/notifications/webhooks-events/#{encode(event_id)}/resend", query: query, body: body, headers: headers)
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Simulate webhook event
|
65
|
+
#
|
66
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#simulate-event_post
|
67
|
+
#
|
68
|
+
# @macro request
|
69
|
+
#
|
70
|
+
def simulate(query: nil, body: nil, headers: nil)
|
71
|
+
client.post("/v1/notifications/simulate-event", query: query, body: body, headers: headers)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
include APIs
|
76
|
+
extend APIs
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaypalAPI
|
4
|
+
#
|
5
|
+
# https://developer.paypal.com/docs/api/webhooks/v1/
|
6
|
+
#
|
7
|
+
class WebhookLookups < 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 lookup
|
20
|
+
#
|
21
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_post
|
22
|
+
#
|
23
|
+
# @macro request
|
24
|
+
#
|
25
|
+
def create(query: nil, body: nil, headers: nil)
|
26
|
+
client.post("/v1/notifications/webhooks-lookup", query: query, body: body, headers: headers)
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# List webhook lookups
|
31
|
+
#
|
32
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_list
|
33
|
+
#
|
34
|
+
# @macro request
|
35
|
+
#
|
36
|
+
def list(query: nil, body: nil, headers: nil)
|
37
|
+
client.get("/v1/notifications/webhooks-lookup", query: query, body: body, headers: headers)
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Show webhook lookup details
|
42
|
+
#
|
43
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_get
|
44
|
+
#
|
45
|
+
# @param webhook_lookup_id [String] Webhook lookup ID
|
46
|
+
# @macro request
|
47
|
+
#
|
48
|
+
def show(webhook_lookup_id, query: nil, body: nil, headers: nil)
|
49
|
+
client.get("/v1/notifications/webhooks-lookup/#{encode(webhook_lookup_id)}", query: query, body: body, headers: headers)
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Delete webhook lookup
|
54
|
+
#
|
55
|
+
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks-lookup_delete
|
56
|
+
#
|
57
|
+
# @param webhook_lookup_id [String] Webhook lookup ID
|
58
|
+
# @macro request
|
59
|
+
#
|
60
|
+
def delete(webhook_lookup_id, query: nil, body: nil, headers: nil)
|
61
|
+
client.delete("/v1/notifications/webhooks-lookup/#{encode(webhook_lookup_id)}", query: query, body: body, headers: headers)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
include APIs
|
66
|
+
extend APIs
|
67
|
+
end
|
68
|
+
end
|