-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new filters options to graphql and export of credit notes
- Loading branch information
Showing
13 changed files
with
924 additions
and
109 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutations | ||
module DataExports | ||
module CreditNotes | ||
class Create < BaseMutation | ||
include AuthenticableApiUser | ||
include RequiredOrganization | ||
|
||
REQUIRED_PERMISSION = 'credit_notes:export' | ||
|
||
graphql_name 'CreateCreditNotesDataExport' | ||
description 'Request data export of credit notes' | ||
|
||
input_object_class Types::DataExports::CreditNotes::CreateInput | ||
|
||
type Types::DataExports::Object | ||
|
||
def resolve(format:, filters:, resource_type:) | ||
result = ::DataExports::CreateService | ||
.call( | ||
organization: current_organization, | ||
user: context[:current_user], | ||
format:, | ||
resource_type:, | ||
resource_query: filters | ||
) | ||
|
||
result.success? ? result.data_export : result_error(result) | ||
end | ||
end | ||
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
15 changes: 15 additions & 0 deletions
15
app/graphql/types/data_exports/credit_notes/create_input.rb
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module DataExports | ||
module CreditNotes | ||
class CreateInput < Types::BaseInputObject | ||
graphql_name 'CreateDataExportsCreditNotesInput' | ||
|
||
argument :filters, Types::DataExports::CreditNotes::FiltersInput | ||
argument :format, Types::DataExports::FormatTypeEnum | ||
argument :resource_type, Types::DataExports::CreditNotes::ExportTypeEnum | ||
end | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
app/graphql/types/data_exports/credit_notes/export_type_enum.rb
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module DataExports | ||
module CreditNotes | ||
class ExportTypeEnum < Types::BaseEnum | ||
graphql_name 'CreditNoteExportTypeEnum' | ||
|
||
value 'credit_notes' | ||
value 'credit_note_items' | ||
end | ||
end | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
app/graphql/types/data_exports/credit_notes/filters_input.rb
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
module DataExports | ||
module CreditNotes | ||
class FiltersInput < BaseInputObject | ||
graphql_name 'DataExportCreditNoteFiltersInput' | ||
description 'Export credit notes search query and filters input argument' | ||
|
||
argument :amount_from, Integer, required: false | ||
argument :amount_to, Integer, required: false | ||
argument :credit_status, [Types::CreditNotes::CreditStatusTypeEnum], required: false | ||
argument :currency, Types::CurrencyEnum, required: false | ||
argument :customer_external_id, String, required: false | ||
argument :customer_id, ID, required: false, description: 'Uniq ID of the customer' | ||
argument :invoice_number, String, required: false | ||
argument :issuing_date_from, GraphQL::Types::ISO8601Date, required: false | ||
argument :issuing_date_to, GraphQL::Types::ISO8601Date, required: false | ||
argument :reason, [Types::CreditNotes::ReasonTypeEnum], required: false | ||
argument :refund_status, [Types::CreditNotes::RefundStatusTypeEnum], required: false | ||
argument :search_term, String, required: false | ||
end | ||
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
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.