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

Changing api endpoint to new url #2

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

const (
defaultBaseURL = "https://www.fio.cz/"
defaultBaseURL = "https://fioapi.fio.cz/"
dateFormat = "2006-01-02"
)

Expand Down
12 changes: 6 additions & 6 deletions transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type TransactionsService struct {

// ByPeriod returns transactions in date period.
func (s *TransactionsService) ByPeriod(ctx context.Context, opts ByPeriodOptions) (*TransactionsResponse, error) {
urlStr := s.client.buildURL("ib_api/rest/periods", fmtDate(opts.DateFrom), fmtDate(opts.DateTo), "transactions.xml")
urlStr := s.client.buildURL("v1/rest/periods", fmtDate(opts.DateFrom), fmtDate(opts.DateTo), "transactions.xml")
req, err := s.client.newGetRequest(ctx, urlStr)
if err != nil {
return nil, err
Expand All @@ -95,7 +95,7 @@ type ExportOptions struct {
// Export writes transactions in date period to provided writer.
func (s *TransactionsService) Export(ctx context.Context, opts ExportOptions, w io.Writer) error {
exportFmt := fmt.Sprintf("transactions.%v", opts.Format)
urlStr := s.client.buildURL("ib_api/rest/periods", fmtDate(opts.DateFrom), fmtDate(opts.DateTo), exportFmt)
urlStr := s.client.buildURL("v1/rest/periods", fmtDate(opts.DateFrom), fmtDate(opts.DateTo), exportFmt)
req, err := s.client.newGetRequest(ctx, urlStr)
if err != nil {
return err
Expand All @@ -119,7 +119,7 @@ type GetStatementOptions struct {

// GetStatement returns statement by its year/id.
func (s *TransactionsService) GetStatement(ctx context.Context, opts GetStatementOptions) (*TransactionsResponse, error) {
urlStr := s.client.buildURL("ib_api/rest/by-id", strconv.Itoa(opts.Year), strconv.Itoa(opts.ID), "transactions.xml")
urlStr := s.client.buildURL("v1/rest/by-id", strconv.Itoa(opts.Year), strconv.Itoa(opts.ID), "transactions.xml")
req, err := s.client.newGetRequest(ctx, urlStr)
if err != nil {
return nil, err
Expand All @@ -143,7 +143,7 @@ type ExportStatementOptions struct {
// ExportStatement writes statement by its year/id to provided writer.
func (s *TransactionsService) ExportStatement(ctx context.Context, opts ExportStatementOptions, w io.Writer) error {
exportFmt := fmt.Sprintf("transactions.%v", opts.Format)
urlStr := s.client.buildURL("ib_api/rest/by-id", strconv.Itoa(opts.Year), strconv.Itoa(opts.ID), exportFmt)
urlStr := s.client.buildURL("v1/rest/by-id", strconv.Itoa(opts.Year), strconv.Itoa(opts.ID), exportFmt)
req, err := s.client.newGetRequest(ctx, urlStr)
if err != nil {
return err
Expand Down Expand Up @@ -183,7 +183,7 @@ type SetLastDownloadIDOptions struct {

// SetLastDownloadID sets the last downloaded id of statement.
func (s *TransactionsService) SetLastDownloadID(ctx context.Context, opts SetLastDownloadIDOptions) error {
urlStr := s.client.buildURL("ib_api/rest/set-last-id", strconv.Itoa(opts.ID), "")
urlStr := s.client.buildURL("v1/rest/set-last-id", strconv.Itoa(opts.ID), "")
req, err := s.client.newGetRequest(ctx, urlStr)
if err != nil {
return err
Expand All @@ -203,7 +203,7 @@ type SetLastDownloadDateOptions struct {

// SetLastDownloadDate sets the last download date of statement.
func (s *TransactionsService) SetLastDownloadDate(ctx context.Context, opts SetLastDownloadDateOptions) error {
urlStr := s.client.buildURL("ib_api/rest/set-last-date", fmtDate(opts.Date), "")
urlStr := s.client.buildURL("v1/rest/set-last-date", fmtDate(opts.Date), "")
req, err := s.client.newGetRequest(ctx, urlStr)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestByPeriod(t *testing.T) {

dateFrom := time.Now()
dateTo := time.Now()
urlStr := fmt.Sprintf("/ib_api/rest/periods/%v/%v/%v/transactions.xml", testingToken, fmtDate(dateFrom), fmtDate(dateTo))
urlStr := fmt.Sprintf("/v1/rest/periods/%v/%v/%v/transactions.xml", testingToken, fmtDate(dateFrom), fmtDate(dateTo))

mux.HandleFunc(urlStr, func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, http.MethodGet, r.Method)
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestExport(t *testing.T) {
testingFormat := JSONFormat
dateFrom := time.Now()
dateTo := time.Now()
urlStr := fmt.Sprintf("/ib_api/rest/periods/%v/%v/%v/transactions.%v", testingToken, fmtDate(dateFrom), fmtDate(dateTo), testingFormat)
urlStr := fmt.Sprintf("/v1/rest/periods/%v/%v/%v/transactions.%v", testingToken, fmtDate(dateFrom), fmtDate(dateTo), testingFormat)

mux.HandleFunc(urlStr, func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, http.MethodGet, r.Method)
Expand All @@ -154,7 +154,7 @@ func TestGetStatement(t *testing.T) {

year := 2017
id := 1
urlStr := fmt.Sprintf("/ib_api/rest/by-id/%v/%v/%v/transactions.xml", testingToken, year, id)
urlStr := fmt.Sprintf("/v1/rest/by-id/%v/%v/%v/transactions.xml", testingToken, year, id)

mux.HandleFunc(urlStr, func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, http.MethodGet, r.Method)
Expand Down
Loading