whop 1.0.2 → 1.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.
- checksums.yaml +4 -4
- data/lib/whop/dsl.rb +12 -0
- data/lib/whop/dsl_prelude.rb +91 -7
- data/lib/whop/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 459db38a252c7e59219c39e38a45aaf59d1efc155a3c35cadc82a9200783217e
|
|
4
|
+
data.tar.gz: 8e06ed8ac2da677b869457edcf325ae2300c5705339193f9e0f4f02d5300ae77
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 962fbde15cb871d3fee2a911395eefa63acec49770f27ce513d93a78506d549d754d74925ec1186b7a22083fc50cbb4d144466af82ff34ba985b738a9a579f8c
|
|
7
|
+
data.tar.gz: aa7995d4c5cf75e84bb59d1dbef79e04ba9ebf8ef4cf42b2382b8f99591a7963ccc7809a39a080701412ade691a624e143a4268ba5291f068e01975fdd91da5b
|
data/lib/whop/dsl.rb
CHANGED
|
@@ -24,6 +24,15 @@ module Whop
|
|
|
24
24
|
@methods[method_name.to_sym] = { type: :graphql, operation: operation, args: Array(args).map(&:to_sym) }
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def graphql_inline(method_name, operation:, query:, args: [])
|
|
28
|
+
@methods[method_name.to_sym] = {
|
|
29
|
+
type: :graphql_inline,
|
|
30
|
+
operation: operation,
|
|
31
|
+
query: query,
|
|
32
|
+
args: Array(args).map(&:to_sym)
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
27
36
|
def rest_get(method_name, path:, args: [], params: [])
|
|
28
37
|
@methods[method_name.to_sym] = { type: :rest_get, path: path, args: Array(args).map(&:to_sym), params: Array(params).map(&:to_sym) }
|
|
29
38
|
end
|
|
@@ -63,6 +72,9 @@ module Whop
|
|
|
63
72
|
when :graphql
|
|
64
73
|
variables = build_named_args(spec[:args], args, kwargs)
|
|
65
74
|
@client.graphql(spec[:operation], variables)
|
|
75
|
+
when :graphql_inline
|
|
76
|
+
variables = build_named_args(spec[:args], args, kwargs)
|
|
77
|
+
@client.graphql_query(spec[:operation], spec[:query], variables)
|
|
66
78
|
when :rest_get
|
|
67
79
|
path = interpolate_path(spec[:path], build_named_args(spec[:args], args, kwargs))
|
|
68
80
|
query = kwargs.select { |k, _| spec[:params].include?(k.to_sym) }
|
data/lib/whop/dsl_prelude.rb
CHANGED
|
@@ -34,16 +34,100 @@ Whop::DSL.define do
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
resource :payments do
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
graphql_inline :create_checkout_session,
|
|
38
|
+
operation: "createCheckoutSession",
|
|
39
|
+
args: %i[input],
|
|
40
|
+
query: <<~GQL
|
|
41
|
+
mutation createCheckoutSession($input: CreateCheckoutSessionInput!) {
|
|
42
|
+
createCheckoutSession(input: $input) {
|
|
43
|
+
id
|
|
44
|
+
planId
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
GQL
|
|
48
|
+
|
|
49
|
+
graphql_inline :charge_user,
|
|
50
|
+
operation: "chargeUser",
|
|
51
|
+
args: %i[input],
|
|
52
|
+
query: <<~GQL
|
|
53
|
+
mutation chargeUser($input: ChargeUserInput!) {
|
|
54
|
+
chargeUser(input: $input) {
|
|
55
|
+
status
|
|
56
|
+
inAppPurchase: checkoutSession {
|
|
57
|
+
id
|
|
58
|
+
planId
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
GQL
|
|
63
|
+
|
|
64
|
+
graphql_inline :pay_user,
|
|
65
|
+
operation: "payUser",
|
|
66
|
+
args: %i[input],
|
|
67
|
+
query: <<~GQL
|
|
68
|
+
mutation payUser($input: TransferFundsInput!) {
|
|
69
|
+
transferFunds(input: $input)
|
|
70
|
+
}
|
|
71
|
+
GQL
|
|
72
|
+
|
|
73
|
+
graphql_inline :list_receipts_for_company,
|
|
74
|
+
operation: "listReceiptsForCompany",
|
|
75
|
+
args: %i[companyId first after filter],
|
|
76
|
+
query: <<~GQL
|
|
77
|
+
query listReceiptsForCompany($companyId: ID!, $first: Int, $after: String, $filter: ReceiptV2Filters) {
|
|
78
|
+
company(id: $companyId) {
|
|
79
|
+
receipts: receiptsV2(first: $first, after: $after, filter: $filter) {
|
|
80
|
+
nodes {
|
|
81
|
+
id
|
|
82
|
+
createdAt
|
|
83
|
+
finalAmount
|
|
84
|
+
currency
|
|
85
|
+
}
|
|
86
|
+
pageInfo { hasNextPage endCursor }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
GQL
|
|
41
91
|
end
|
|
42
92
|
|
|
43
93
|
resource :invoices do
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
94
|
+
graphql_inline :create_invoice,
|
|
95
|
+
operation: "createInvoice",
|
|
96
|
+
args: %i[input],
|
|
97
|
+
query: <<~GQL
|
|
98
|
+
mutation createInvoice($input: CreateInvoiceInput!) {
|
|
99
|
+
createInvoice(input: $input) {
|
|
100
|
+
invoice { id number status createdAt }
|
|
101
|
+
checkoutJobId
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
GQL
|
|
105
|
+
|
|
106
|
+
graphql_inline :get_invoice,
|
|
107
|
+
operation: "getInvoice",
|
|
108
|
+
args: %i[invoiceId companyId],
|
|
109
|
+
query: <<~GQL
|
|
110
|
+
query getInvoice($invoiceId: ID!, $companyId: ID!) {
|
|
111
|
+
company(id: $companyId) {
|
|
112
|
+
invoice(id: $invoiceId) { id number status createdAt }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
GQL
|
|
116
|
+
|
|
117
|
+
graphql_inline :list_invoices,
|
|
118
|
+
operation: "listInvoices",
|
|
119
|
+
args: %i[companyId after before first last],
|
|
120
|
+
query: <<~GQL
|
|
121
|
+
query listInvoices($companyId: ID!, $after: String, $before: String, $first: Int, $last: Int) {
|
|
122
|
+
company(id: $companyId) {
|
|
123
|
+
invoices(after: $after, before: $before, first: $first, last: $last) {
|
|
124
|
+
totalCount
|
|
125
|
+
pageInfo { endCursor hasNextPage hasPreviousPage startCursor }
|
|
126
|
+
nodes { id number status createdAt }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
GQL
|
|
47
131
|
end
|
|
48
132
|
|
|
49
133
|
resource :promo_codes do
|
data/lib/whop/version.rb
CHANGED