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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b66a5c1ff726bf0d3142a0d2f3263f990c114f1de42c05dfe3d564d63719e702
4
- data.tar.gz: c36bc051232dafa141659f0a11df945f5ce06aa8b852ae37504b752d72ed2cfc
3
+ metadata.gz: 459db38a252c7e59219c39e38a45aaf59d1efc155a3c35cadc82a9200783217e
4
+ data.tar.gz: 8e06ed8ac2da677b869457edcf325ae2300c5705339193f9e0f4f02d5300ae77
5
5
  SHA512:
6
- metadata.gz: 13b4f042216946a03e922f4c7642c6b8a478b3ea95b9c3e727a39e756f989ad7ae6cf248e7dfa74a3101637ea3eef5c9e89acf80d7cd4a322067c0eb4e529cf2
7
- data.tar.gz: 417ab6ac4239fbe3bbbdccb3a7bf41326e847152318658449fc92fd74e28b2999ac556a8a27656322235eaf74e3ecafe384191a074a1030b15a6fa07ebef72b6
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) }
@@ -34,16 +34,100 @@ Whop::DSL.define do
34
34
  end
35
35
 
36
36
  resource :payments do
37
- graphql :create_checkout_session, operation: "createCheckoutSession", args: %i[input]
38
- graphql :charge_user, operation: "chargeUser", args: %i[input]
39
- graphql :pay_user, operation: "payUser", args: %i[input]
40
- graphql :list_receipts_for_company, operation: "listReceiptsForCompany", args: %i[companyId first after filter]
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
- graphql :create_invoice, operation: "createInvoice", args: %i[input]
45
- graphql :get_invoice, operation: "getInvoice", args: %i[invoiceId companyId]
46
- graphql :list_invoices, operation: "listInvoices", args: %i[companyId after before first last]
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
@@ -1,5 +1,5 @@
1
1
  module Whop
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
4
4
 
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikhil Nelson