-
Notifications
You must be signed in to change notification settings - Fork 43
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
omise-go v2 (codegen) #42
base: master
Are you sure you want to change the base?
Conversation
25c36e1
to
76a4402
Compare
Could you add newline at the end of file of generated file? |
Sure krub. Thank you. |
5aafb1f
to
80be80a
Compare
Add type alias and rename based struct for List Regenerate *_list.go Generate resource files (wip) Remove Base struct + regenerate request files Prepend omise package prefix to field type + auto import package Generate nested resources (wip) Add resource prefix for list actions Fix duplicate refund struct types Append List struct to list operations Update ordering path to v2 Generate extra params for endpoints Regenerate operations/* Generate all params Generate Vault endpoint for token Update test to include v2 Update fixtures path Generate comments Ignore golint for now (focus on tests) Generate omitempty tags Generate struct pointers Reorder json fields in tests Regenerate int64 and int types Update fixtures path Force non-null fields Generate *bool for charge.capture Generate documentation (wip) Generate documentation (wip) Add tests for capability Generate float64 for floating point fields Add tests for forex Add DateString type for date fields in params Generate custom DateString type Fix test failed due to case-sensitivity in linux Update tests for schedule + make Weekday non-pointer Fix more tests in schedule resource Make Schedule's start_date and end_date nullable Generate ListChargeSchedules struct Re-generate ListChargeSchedules struct Make enum types non-reference Update tests and fixtures for source Add tests for system_info (/) Generate search types Re-generate event.data Update tests for schedule Add network tests for source Re-enable golint for v2 Add comments for enums Generate comments for enums Generate more comments Remove old codes Regenerate files with newlines at the end of files Regenerate files with newlines at the end of files (cont) Regenerate files with newlines at the end of files (cont) Regenerate files with newlines at the end of files (done) Cleanup go mod dependencies
Update new API design Update method description Update method description (cont) Update method description (cont) Update method description (cont) Update method description (cont) Update Account tests Update Balance tests Update Capability tests Update Card tests Update Charge tests Update Charge tests (github's down) Update Charge tests Add default API Version Update Charge tests Update Customer tests Fix wrong version in client_test Regenerate list resources Regenerate dispute resource Update Event/Forex/Link tests Update List tests Update Occurrence tests Update Recipient tests + Regenerate params Update Refund tests Update Source tests Update SystemInfo tests Update Transaction tests Update Transfer tests Update Token tests Update Schedule tests Update Search tests Update Search tests Regenerate Search resource Regenerate ChargeStatus Add context support Use req.Context instead of NewRequestWithContext due to go versions (1.13+) Refactor Client.Do
I think this need to run |
|
||
// UnmarshalJSON Date type | ||
func (d *Date) UnmarshalJSON(b []byte) error { | ||
tm, err := time.Parse("\"2006-01-02\"", string(b)) |
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.
this could be
tm, err := time.Parse(`"2006-01-02"`, string(b))
instead of escaping special characters
|
||
const ( | ||
API Endpoint = "https://api.omise.co" | ||
Vault = "https://vault.omise.co" |
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.
is untyped constant here intended?
"net/http" | ||
) | ||
|
||
var _ = fmt.Println |
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.
is there any reason for fmt
to remains as imported package here?
return ok | ||
} | ||
|
||
func assertJSONEquals(t *testing.T, prefix string, m1 map[string]interface{}, m2 map[string]interface{}) { |
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.
there's https://pkg.go.dev/github.com/stretchr/testify/require?tab=doc#JSONEq for this kind of assertion and it's already imported here. could be use that instead
package omise | ||
|
||
// MfaRecoveryCodes represents resource object. | ||
type MfaRecoveryCodes struct { |
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.
acronym in go should remains all capital case, Mfa
-> MFA
if this is Multi-Factor Authentication here
r "github.com/stretchr/testify/require" | ||
) | ||
|
||
var _ = fmt.Println |
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.
remove this
|
||
client := testutil.NewFixedClient(t) | ||
receipt, _ := client.Receipt().Retrieve(context.Background(), &omise.RetrieveReceiptParams{ReceiptID}) | ||
a.Equal(t, ReceiptID, receipt.ID) |
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.
should check first if receipt
is not nil
if using assert
package, not require
here
otherwise when this fails, everything else will be failed too and produce a lot of useless failure messages since the root cause is nil
.
expected := `{"amount":192188}` | ||
|
||
b, err := json.Marshal(req) | ||
r.Nil(t, err, "err should be nothing") |
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.
use r.NoError(t, err, "err should be nothing")
here
type QrCode struct { | ||
Base | ||
Email string `json:"email"` | ||
MfaProvisioningURI string `json:"mfa_provisioning_uri"` |
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.
Mfa
here should be MFA
or there's some limitations that prevent this kind of naming?
SourceInstallmentKtc SourceType = "installment_ktc" | ||
SourceInternetBankingBay SourceType = "internet_banking_bay" | ||
SourceInternetBankingBbl SourceType = "internet_banking_bbl" | ||
SourceInternetBankingKtb SourceType = "internet_banking_ktb" | ||
SourceInternetBankingScb SourceType = "internet_banking_scb" |
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.
isn't it should be all-capital letters for bank acronym, not camelCase?
"versions": [ | ||
"2019-05-29" | ||
] | ||
} |
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.
newline here please
], | ||
"country": "TH", | ||
"zero_interest_installments": true | ||
} |
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.
newline here please
"base": "USD", | ||
"quote": "THB", | ||
"rate": 30.4847017 | ||
} |
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.
newline here please
"message": null, | ||
"result": null, | ||
"created": "2017-06-08T04:46:50Z" | ||
} |
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.
newline please
"created": "2017-06-08T04:46:50Z" | ||
} | ||
] | ||
} |
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.
newline please
"terminal_id": "POS-01", | ||
"type": "bill_payment_tesco_lotus", | ||
"zero_interest_installments": null | ||
} |
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.
newline please
"terminal_id": "POS-01", | ||
"type": "bill_payment_tesco_lotus", | ||
"zero_interest_installments": null | ||
} |
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.
newline here too please
"name": "JOHN DOE", | ||
"created": "2015-06-02T09:26:59Z" | ||
}, | ||
"created": "2015-01-15T10:04:47Z" |
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.
is missing comma at the end of this line intended?
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Code generation
Testing
New API Design
context
supportNew API Design
Others