Skip to content
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

#177 feature/Invoice: init, added Invoice related structs, implemented met… #249

Merged
merged 2 commits into from
Oct 28, 2022

Conversation

akshayDev17
Copy link
Contributor

feature/Invoice: init, added Invoice related structs, implemented methods:GenerateInvoiceNumber,GetInvoiceDetails(by ID)

What does this PR do?

  1. implements the Invoice related structures that takes care of the endpoints: "/v2/invoicing/generate-next-invoice-number" and "/v2/invoicing/invoices/{invoice_id}", thus addresses this issue.

Where should the reviewer start?

  1. Main-code: types.go; from the structure InvoiceNumber to the structure Invoice
  2. invoicing.go: implements the methods for the endpoints mentioned above.
  3. invoicing_test.go: implements unit-testing functions for the above mentioned methods.

How should this be manually tested?

  1. By running the test functions TestGenerateInvoiceNumber() and TestGetInvoice() in invoicing_test.go using the commands go test -timeout 60s -cover -v -run ^TestGenerateInvoiceNumber and go test -timeout 60s -cover -v -run ^TestGetInvoice respectively.

Any background context you want to provide?

  1. Other Invoicing endpoints will also be addressed in the future commits.
  2. Currently there seems to be no way to implement a generalized function(across different types/structs) for comparing two slices of the same type of struct, where the ordering of the elements within the slices should not be a factor in determining their equality.
    1. l = [1,2,3](data returned by API) and v = [2,3,1](explicitly declared data in a Testing function) is the same(because it might be that the API returns data in a different order).
    2. sorting by one of the fields would be helpful:
      1. but since the field value can be empty(nil), would've to sort across all fields.
      2. currently exploring whether this can be done regardless of the knowledge of the struct(in a programmatical manner), because explicit implementation across all structs would be too cumbersome.

…hods:GenerateInvoiceNumber,GetInvoiceDetails(by ID)
)

// All test values are defined here
var devTestClientID = "AXy9orp-CDaHhBZ9C78QHW2BKZpACgroqo85_NIOa9mIfJ9QnSVKzY-X_rivR_fTUUr6aLjcJsj6sDur"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we don't have any keys in tests, where did you get them? Should we move them to env vars?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I obtained these from the integration_test.go file. They seem to be used in order_test.go as well. Should we ideally be importing them as env vars?


// GenerateInvoiceNumber: generates the next invoice number that is available to the merchant.
// Endpoint: POST /v2/invoicing/generate-next-invoice-number
func (c *Client) GenerateInvoiceNumber(ctx context.Context) (*InvoiceNumber, error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add that to README to the list of supported enspoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in this commit, please review.

@plutov plutov changed the title feature/Invoice: init, added Invoice related structs, implemented met… #177 feature/Invoice: init, added Invoice related structs, implemented met… Oct 27, 2022
@plutov plutov merged commit 4c16ffa into plutov:master Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants