paypal-rest-api 0.0.3 → 0.0.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.
@@ -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 create_subscription(query: nil, body: nil, headers: nil)
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 show_subscription(subscription_id, query: nil, body: nil, headers: nil)
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 update_subscription(subscription_id, query: nil, body: nil, headers: nil)
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 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)
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 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)
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 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)
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 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)
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 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)
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
@@ -46,7 +46,7 @@ module PaypalAPI
46
46
  # @macro request
47
47
  #
48
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)
49
+ client.get("/v1/notifications/webhooks/#{encode(webhook_id)}", query: query, body: body, headers: headers)
50
50
  end
51
51
 
52
52
  #
@@ -58,7 +58,7 @@ module PaypalAPI
58
58
  # @macro request
59
59
  #
60
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)
61
+ client.patch("/v1/notifications/webhooks/#{encode(webhook_id)}", query: query, body: body, headers: headers)
62
62
  end
63
63
 
64
64
  #
@@ -70,7 +70,7 @@ module PaypalAPI
70
70
  # @macro request
71
71
  #
72
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)
73
+ client.delete("/v1/notifications/webhooks/#{encode(webhook_id)}", query: query, body: body, headers: headers)
74
74
  end
75
75
 
76
76
  #
@@ -81,54 +81,8 @@ module PaypalAPI
81
81
  # @param webhook_id [String] Webhook ID
82
82
  # @macro request
83
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)
84
+ def event_types(webhook_id, query: nil, body: nil, headers: nil)
85
+ client.get("/v1/notifications/webhooks/#{encode(webhook_id)}/event-types", query: query, body: body, headers: headers)
132
86
  end
133
87
 
134
88
  #
@@ -141,63 +95,6 @@ module PaypalAPI
141
95
  def verify(query: nil, body: nil, headers: nil)
142
96
  client.post("/v1/notifications/verify-webhook-signature", query: query, body: body, headers: headers)
143
97
  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
98
  end
202
99
 
203
100
  include APIs