-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Feat/Stripe: Added more object of the stripe products categorie #101
Changes from all commits
c424527
6165fa1
015e958
dcd92b4
24c5feb
45a5b77
f73d0ea
50b302d
7a351fe
c12f729
cca9bb8
efed1de
c770df2
3f871e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,8 @@ fn body_to_rows( | |
.and_then(|v| match *col_type { | ||
"bool" => v.as_bool().map(Cell::Bool), | ||
"i64" => v.as_i64().map(Cell::I64), | ||
"f64" => v.as_f64().map(Cell::F64), | ||
"json" => v.as_i64().map(Cell::Json), | ||
"string" => v.as_str().map(|a| Cell::String(a.to_owned())), | ||
"timestamp" => v.as_i64().map(|a| { | ||
let ts = to_timestamp(a as f64); | ||
|
@@ -147,6 +149,9 @@ fn row_to_body(row: &Row) -> JsonValue { | |
Cell::I64(v) => { | ||
map.insert(col_name, JsonValue::Number(Number::from(*v))); | ||
} | ||
Cell::F64(v) => { | ||
map.insert(col_name, JsonValue::Number(Decimal::from(*v))); | ||
} | ||
Cell::String(v) => { | ||
map.insert(col_name, JsonValue::String(v.to_string())); | ||
} | ||
|
@@ -155,6 +160,8 @@ fn row_to_body(row: &Row) -> JsonValue { | |
if let Some(m) = v.0.clone().as_object_mut() { | ||
map.append(m) | ||
} | ||
} else { | ||
map.insert(col_name, v); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious if someone can shed some light on this code if this is the correct implementation for normal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks correct, but that requires the |
||
} | ||
} | ||
_ => { | ||
|
@@ -254,7 +261,7 @@ macro_rules! report_request_error { | |
} | ||
|
||
#[wrappers_fdw( | ||
version = "0.1.7", | ||
version = "0.1.8", | ||
author = "Supabase", | ||
website = "https://github.com/supabase/wrappers/tree/main/wrappers/src/fdw/stripe_fdw", | ||
error_type = "StripeFdwError" | ||
|
@@ -287,6 +294,8 @@ impl StripeFdw { | |
"balance" => vec![], | ||
"balance_transactions" => vec!["type"], | ||
"charges" => vec!["customer"], | ||
"checkout/sessions" => vec!["customer", "payment_intent", "subscription"], | ||
"coupons" => vec![], | ||
"customers" => vec!["email"], | ||
"disputes" => vec!["charge", "payment_intent"], | ||
"events" => vec!["type"], | ||
|
@@ -298,14 +307,17 @@ impl StripeFdw { | |
"payouts" => vec!["status"], | ||
"prices" => vec!["active", "currency", "product", "type"], | ||
"products" => vec!["active"], | ||
"promotion_codes" => vec![], | ||
"refunds" => vec!["charge", "payment_intent"], | ||
"setup_attempts" => vec!["setup_intent"], | ||
"setup_intents" => vec!["customer", "payment_method"], | ||
"shipping_rates" => vec!["active", "created", "currency"], | ||
"subscriptions" => vec!["customer", "price", "status"], | ||
"tax_codes" => vec![], | ||
"tax_rates" => vec!["active"], | ||
"tokens" => vec![], | ||
"topups" => vec!["status"], | ||
"transfers" => vec!["destination"], | ||
"checkout/sessions" => vec!["customer", "payment_intent", "subscription"], | ||
_ => { | ||
report_error( | ||
PgSqlErrorCode::ERRCODE_FDW_TABLE_NOT_FOUND, | ||
|
@@ -378,6 +390,32 @@ impl StripeFdw { | |
], | ||
tgt_cols, | ||
), | ||
"checkout/sessions" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
("id", "string"), | ||
("customer", "string"), | ||
("payment_intent", "string"), | ||
("subscription", "string"), | ||
("created", "timestamp"), | ||
], | ||
tgt_cols, | ||
), | ||
"coupons" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
("id", "string"), | ||
("amount_off", "i64"), | ||
("currency", "string"), | ||
("duration", "string"), | ||
("duration_in_months", "i64"), | ||
("max_redemptions", "i64"), | ||
("name", "string"), | ||
("percent_off", "f64"), | ||
("created", "timestamp"), | ||
], | ||
tgt_cols, | ||
), | ||
"customers" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
|
@@ -516,6 +554,17 @@ impl StripeFdw { | |
], | ||
tgt_cols, | ||
), | ||
"promotion_codes" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
("id", "string"), | ||
("code", "string"), | ||
("coupon", "string"), | ||
("active", "bool"), | ||
("created", "timestamp"), | ||
], | ||
tgt_cols, | ||
), | ||
"refunds" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
|
@@ -559,6 +608,18 @@ impl StripeFdw { | |
], | ||
tgt_cols, | ||
), | ||
"shipping_rates" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
("id", "string"), | ||
("active", "bool"), | ||
("display_name", "string"), | ||
("amount", "string"), | ||
("type", "string"), | ||
("created", "timestamp"), | ||
], | ||
tgt_cols, | ||
), | ||
"subscriptions" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
|
@@ -570,6 +631,27 @@ impl StripeFdw { | |
], | ||
tgt_cols, | ||
), | ||
"tax_codes" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
("id", "string"), | ||
("description", "string"), | ||
("name", "string"), | ||
], | ||
tgt_cols, | ||
), | ||
"tax_rates" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
("id", "string"), | ||
("active", "bool"), | ||
("country", "string"), | ||
("description", "string"), | ||
("display_name", "string"), | ||
("inclusive", "bool"), | ||
("percentage", "f64"), | ||
("created", "timestamp"), | ||
), | ||
"tokens" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
|
@@ -605,17 +687,6 @@ impl StripeFdw { | |
], | ||
tgt_cols, | ||
), | ||
"checkout/sessions" => body_to_rows( | ||
resp_body, | ||
vec![ | ||
("id", "string"), | ||
("customer", "string"), | ||
("payment_intent", "string"), | ||
("subscription", "string"), | ||
("created", "timestamp"), | ||
], | ||
tgt_cols, | ||
), | ||
_ => { | ||
report_error( | ||
PgSqlErrorCode::ERRCODE_FDW_TABLE_NOT_FOUND, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is correct... maybe I should first learn how rust works...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is correct for
f64
, but forjson
I think it is better to use string convert in between.