-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
368 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Paddle | ||
class Report < Object | ||
|
||
class << self | ||
|
||
def list(**params) | ||
response = Client.get_request("reports", params: params) | ||
Collection.from_response(response, type: Report) | ||
end | ||
|
||
def create(type:, filters:, **params) | ||
attrs = {type: type, filters: filters} | ||
response = Client.post_request("reports", body: attrs.merge(params)) | ||
Report.new(response.body["data"]) | ||
end | ||
|
||
def retrieve(id:) | ||
response = Client.get_request("reports/#{id}") | ||
Report.new(response.body["data"]) | ||
end | ||
|
||
def csv(id:) | ||
response = Client.get_request("reports/#{id}/download-url") | ||
if response.success? | ||
return response.body["data"]["url"] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "test_helper" | ||
|
||
class ReportTest < Minitest::Test | ||
|
||
def test_report_list | ||
reports = Paddle::Report.list | ||
|
||
assert_equal Paddle::Collection, reports.class | ||
assert_equal Paddle::Report, reports.data.first.class | ||
assert_equal "rep_01hw8a1mg788ffxetyzs77vk3n", reports.data.first.id | ||
end | ||
|
||
def test_report_retrieve | ||
report = Paddle::Report.retrieve(id: "rep_01hw8a1mg788ffxetyzs77vk3n") | ||
|
||
assert_equal Paddle::Report, report.class | ||
assert_equal "rep_01hw8a1mg788ffxetyzs77vk3n", report.id | ||
assert_equal "transactions", report.type | ||
end | ||
|
||
def test_report_csv | ||
csv = Paddle::Report.csv(id: "rep_01hw8a1mg788ffxetyzs77vk3n") | ||
|
||
assert_match (/sandbox-reports/), csv | ||
end | ||
|
||
def test_report_create | ||
report = Paddle::Report.create( | ||
type: "transactions", | ||
filters: [ | ||
{name: "updated_at", operator: "lt", value: "2024-04-30"}, | ||
{name: "updated_at", operator: "gte", value: "2024-04-01"} | ||
] | ||
) | ||
|
||
assert_equal Paddle::Report, report.class | ||
assert_equal "transactions", report.type | ||
end | ||
|
||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.