-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dunning): Add resolver for payment requests
- Loading branch information
Showing
12 changed files
with
453 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,3 +84,5 @@ organization: | |
create: | ||
update: | ||
delete: | ||
payment_requests: | ||
view: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,5 @@ organization: | |
create: false | ||
update: false | ||
delete: false | ||
payment_requests: | ||
view: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,5 @@ organization: | |
create: false | ||
update: false | ||
delete: false | ||
payment_requests: | ||
view: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module Resolvers | ||
class PaymentRequestsResolver < Resolvers::BaseResolver | ||
include AuthenticableApiUser | ||
include RequiredOrganization | ||
|
||
REQUIRED_PERMISSION = "payment_requests:view" | ||
|
||
description "Query payment requests of an organization" | ||
|
||
argument :external_customer_id, String, required: false | ||
argument :limit, Integer, required: false | ||
argument :page, Integer, required: false | ||
|
||
type Types::PaymentRequests::Object.collection_type, null: false | ||
|
||
def resolve(page: nil, limit: nil, external_customer_id: nil) | ||
result = PaymentRequestsQuery.call( | ||
organization: current_organization, | ||
filters: { | ||
external_customer_id: | ||
}, | ||
pagination: { | ||
page:, | ||
limit: | ||
} | ||
) | ||
|
||
result.payment_requests | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module PaymentRequests | ||
class Object < Types::BaseObject | ||
graphql_name "PaymentRequest" | ||
|
||
field :id, ID, null: false | ||
|
||
field :amount_cents, GraphQL::Types::BigInt, null: false | ||
field :amount_currency, Types::CurrencyEnum, null: false | ||
field :created_at, GraphQL::Types::ISO8601DateTime, null: false | ||
field :email, String, null: false | ||
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false | ||
|
||
field :customer, Types::Customers::Object, null: false | ||
field :invoices, [Types::Invoices::Object], null: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.