From 0cc9000757f21c099c2a038a8783cf60ddfe1612 Mon Sep 17 00:00:00 2001 From: Jolan Date: Sat, 14 Nov 2020 03:47:31 +0100 Subject: [PATCH] refactor: removal of dead endpoints (#85) --- client/blocks.go | 12 -- client/blocks_requests.go | 24 ---- client/blocks_test.go | 101 -------------- client/bridgechain_requests.go | 17 --- client/bridgechains.go | 56 -------- client/bridgechains_responses.go | 26 ---- client/bridgechains_test.go | 179 ------------------------ client/businesses.go | 70 ---------- client/businesses_requests.go | 16 --- client/businesses_responses.go | 30 ----- client/businesses_test.go | 225 ------------------------------- client/client.go | 4 - client/locks.go | 12 -- client/locks_requests.go | 15 +-- client/locks_test.go | 75 ----------- client/transactions.go | 12 -- client/transactions_requests.go | 16 --- client/transactions_test.go | 83 ------------ client/wallets.go | 12 -- client/wallets_requests.go | 21 --- client/wallets_test.go | 57 -------- 21 files changed, 1 insertion(+), 1062 deletions(-) delete mode 100644 client/blocks_requests.go delete mode 100644 client/bridgechain_requests.go delete mode 100644 client/bridgechains.go delete mode 100644 client/bridgechains_responses.go delete mode 100644 client/bridgechains_test.go delete mode 100644 client/businesses.go delete mode 100644 client/businesses_requests.go delete mode 100644 client/businesses_responses.go delete mode 100644 client/businesses_test.go delete mode 100644 client/wallets_requests.go diff --git a/client/blocks.go b/client/blocks.go index 0c0ca73..5863c97 100644 --- a/client/blocks.go +++ b/client/blocks.go @@ -80,15 +80,3 @@ func (s *BlocksService) Transactions(ctx context.Context, id int64, query *Pagin return responseStruct, resp, err } - -// Filter all blocks by the given criteria. -func (s *BlocksService) Search(ctx context.Context, query *Pagination, body *BlocksSearchRequest) (*Blocks, *http.Response, error) { - var responseStruct *Blocks - resp, err := s.client.SendRequest(ctx, "POST", "blocks/search", query, body, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} diff --git a/client/blocks_requests.go b/client/blocks_requests.go deleted file mode 100644 index bde6191..0000000 --- a/client/blocks_requests.go +++ /dev/null @@ -1,24 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -type BlocksSearchRequest struct { - Id string `json:"id,omitempty"` - Version uint16 `json:"version,omitempty"` - PreviousBlock string `json:"previousBlock,omitempty"` - PayloadHash string `json:"payloadHash,omitempty"` - GeneratorPublicKey string `json:"generatorPublicKey,omitempty"` - BlockSignature string `json:"blockSignature,omitempty"` - Timestamp *FromTo `json:"timestamp,omitempty"` - Height *FromTo `json:"height,omitempty"` - NumberOfTransactions *FromTo `json:"numberOfTransactions,omitempty"` - TotalAmount *FromTo `json:"totalAmount,omitempty"` - TotalFee *FromTo `json:"totalFee,omitempty"` - Reward *FromTo `json:"reward,omitempty"` - PayloadLength *FromTo `json:"payloadLength,omitempty"` -} diff --git a/client/blocks_test.go b/client/blocks_test.go index d3950b4..acd8eca 100644 --- a/client/blocks_test.go +++ b/client/blocks_test.go @@ -424,104 +424,3 @@ func TestBlocksService_Transactions(t *testing.T) { }}, }) } - -// Filter all blocks by the given criteria. -func TestBlocksService_Search(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/blocks/search", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "POST") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/blocks/search?page=1&limit=1", - "first": "/api/blocks/search?page=1&limit=1", - "last": "/api/blocks/search?page=1&limit=1" - }, - "data": [ - { - "id": "dummy", - "version": 0, - "height": 10, - "previous": "dummy", - "forged": { - "reward": "200000000", - "fee": "0", - "total": "200000000", - "amount": "0" - }, - "payload": { - "hash": "dummy", - "length": 0 - }, - "generator": { - "username": "dummy", - "address": "dummy", - "publicKey": "dummy" - }, - "signature": "dummy", - "confirmations": 0, - "transactions": 0, - "timestamp": { - "epoch": 40678848, - "unix": 1530780048, - "human": "2018-07-05T08:40:48Z" - } - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - body := &BlocksSearchRequest{Id: "dummy"} - responseStruct, response, err := client.Blocks.Search(context.Background(), query, body) - testGeneralError(t, "Blocks.Search", err) - testResponseUrl(t, "Blocks.Search", response, "/api/blocks/search") - testResponseStruct(t, "Blocks.Search", responseStruct, &Blocks{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/blocks/search?page=1&limit=1", - First: "/api/blocks/search?page=1&limit=1", - Last: "/api/blocks/search?page=1&limit=1", - }, - Data: []Block{{ - Id: "dummy", - Version: 0, - Height: 10, - Previous: "dummy", - Forged: BlockForged{ - Reward: 200000000, - Fee: 0, - Total: 200000000, - Amount: 0, - }, - Payload: BlockPayload{ - Hash: "dummy", - Length: 0, - }, - Generator: BlockGenerator{ - Username: "dummy", - Address: "dummy", - PublicKey: "dummy", - }, - Signature: "dummy", - Confirmations: 0, - Transactions: 0, - Timestamp: Timestamp{ - Epoch: 40678848, - Unix: 1530780048, - Human: "2018-07-05T08:40:48Z", - }, - }}, - }) -} diff --git a/client/bridgechain_requests.go b/client/bridgechain_requests.go deleted file mode 100644 index ff1d46b..0000000 --- a/client/bridgechain_requests.go +++ /dev/null @@ -1,17 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -type BridgechainsSearchRequest struct { - BridgechainId uint16 `json:"bridgechainId,omitempty"` - BusinessId uint16 `json:"businessId,omitempty"` - Name string `json:"name,omitempty"` - SeedNodes []string `json:"website,omitempty"` - GenesisHash string `json:"vat,omitempty"` - BridgechainRepository string `json:"repository,omitempty"` -} diff --git a/client/bridgechains.go b/client/bridgechains.go deleted file mode 100644 index 87ba565..0000000 --- a/client/bridgechains.go +++ /dev/null @@ -1,56 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -import ( - "context" - "fmt" - "net/http" -) - -// BridgechainsService handles communication with the bridgechains related -// methods of the Ark Core API - Version 2. -type BridgechainsService Service - -// Get all bridgechains. -func (s *BridgechainsService) List(ctx context.Context, query *Pagination) (*Bridgechains, *http.Response, error) { - var responseStruct *Bridgechains - resp, err := s.client.SendRequest(ctx, "GET", "bridgechains", query, nil, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} - -// Get a bridgechains by the given id. -func (s *BridgechainsService) Get(ctx context.Context, id uint16) (*GetBridgechain, *http.Response, error) { - uri := fmt.Sprintf("bridgechains/%v", id) - - var responseStruct *GetBridgechain - resp, err := s.client.SendRequest(ctx, "GET", uri, nil, nil, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} - -// Filter all bridgechains by the given criteria. -func (s *BridgechainsService) Search(ctx context.Context, query *Pagination, body *BridgechainsSearchRequest) (*Bridgechains, *http.Response, error) { - var responseStruct *Bridgechains - resp, err := s.client.SendRequest(ctx, "POST", "bridgechains/search", query, body, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} diff --git a/client/bridgechains_responses.go b/client/bridgechains_responses.go deleted file mode 100644 index 7358107..0000000 --- a/client/bridgechains_responses.go +++ /dev/null @@ -1,26 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -type Bridgechain struct { - BridgechainId uint16 `json:"bridgechainId,omitempty"` - BusinessId uint16 `json:"businessId,omitempty"` - Name string `json:"name,omitempty"` - SeedNodes []string `json:"seedNodes,omitempty"` - GenesisHash string `json:"genesisHash,omitempty"` - BridgechainRepository string `json:"bridgechainRepository,omitempty"` -} - -type Bridgechains struct { - Meta Meta `json:"meta,omitempty"` - Data []Bridgechain `json:"data,omitempty"` -} - -type GetBridgechain struct { - Data Bridgechain `json:"data,omitempty"` -} diff --git a/client/bridgechains_test.go b/client/bridgechains_test.go deleted file mode 100644 index 09fa892..0000000 --- a/client/bridgechains_test.go +++ /dev/null @@ -1,179 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -import ( - "context" - "fmt" - "net/http" - "testing" -) - -// Get all bridgechains. -func TestBridgechainsService_List(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/bridgechains", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "GET") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/bridgechains?page=1&limit=1", - "first": "/api/bridgechains?page=1&limit=1", - "last": "/api/bridgechains?page=1&limit=1" - }, - "data": [ - { - "bridgechainId": 1, - "businessId": 1, - "name": "dummyName", - "seedNodes": [ - "1.1.1.1" - ], - "genesisHash": "dummyGenesisHash", - "bridgechainRepository": "dummyBridgechainRepository" - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - responseStruct, response, err := client.Bridgechains.List(context.Background(), query) - testGeneralError(t, "Bridgechains.List", err) - testResponseUrl(t, "Bridgechains.List", response, "/api/bridgechains") - testResponseStruct(t, "Bridgechains.List", responseStruct, &Bridgechains{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/bridgechains?page=1&limit=1", - First: "/api/bridgechains?page=1&limit=1", - Last: "/api/bridgechains?page=1&limit=1", - }, - Data: []Bridgechain{{ - BridgechainId: 1, - BusinessId: 1, - Name: "dummyName", - SeedNodes: []string{ - "1.1.1.1", - }, - GenesisHash: "dummyGenesisHash", - BridgechainRepository: "dummyBridgechainRepository", - }}, - }) -} - -// Get a bridgechain by the given id -func TestBridgechainsService_Get(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/bridgechains/1", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "GET") - fmt.Fprint(writer, - `{ - "data": { - "bridgechainId": 1, - "businessId": 1, - "name": "dummyName", - "seedNodes": [ - "1.1.1.1" - ], - "genesisHash": "dummyGenesisHash", - "bridgechainRepository": "dummyBridgechainRepository" - } - }`) - }) - - responseStruct, response, err := client.Bridgechains.Get(context.Background(), 1) - testGeneralError(t, "Bridgechains.Get", err) - testResponseUrl(t, "Bridgechains.Get", response, "/bridgechains/1") - testResponseStruct(t, "Bridgechains.Get", responseStruct, &GetBridgechain{ - Data: Bridgechain{ - BridgechainId: 1, - BusinessId: 1, - Name: "dummyName", - SeedNodes: []string{ - "1.1.1.1", - }, - GenesisHash: "dummyGenesisHash", - BridgechainRepository: "dummyBridgechainRepository", - }, - }) -} - -// Filter all bridgechains by the given criteria. -func TestBridgechainsService_Search(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/bridgechains/search", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "POST") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/bridgechains/search?page=1&limit=1", - "first": "/api/bridgechains/search?page=1&limit=1", - "last": "/api/bridgechains/search?page=1&limit=1" - }, - "data": [ - { - "bridgechainId": 1, - "businessId": 1, - "name": "dummyName", - "seedNodes": [ - "1.1.1.1" - ], - "genesisHash": "dummyGenesisHash", - "bridgechainRepository": "dummyBridgechainRepository" - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - body := &BridgechainsSearchRequest{BridgechainId: 1} - responseStruct, response, err := client.Bridgechains.Search(context.Background(), query, body) - testGeneralError(t, "Bridgechains.Search", err) - testResponseUrl(t, "Bridgechains.Search", response, "/api/bridgechains/search") - testResponseStruct(t, "Bridgechains.Search", responseStruct, &Bridgechains{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/bridgechains/search?page=1&limit=1", - First: "/api/bridgechains/search?page=1&limit=1", - Last: "/api/bridgechains/search?page=1&limit=1", - }, - Data: []Bridgechain{{ - BridgechainId: 1, - BusinessId: 1, - Name: "dummyName", - SeedNodes: []string{ - "1.1.1.1", - }, - GenesisHash: "dummyGenesisHash", - BridgechainRepository: "dummyBridgechainRepository", - }}, - }) -} diff --git a/client/businesses.go b/client/businesses.go deleted file mode 100644 index adf7a37..0000000 --- a/client/businesses.go +++ /dev/null @@ -1,70 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -import ( - "context" - "fmt" - "net/http" -) - -// BusinessesService handles communication with the businesses related -// methods of the Ark Core API - Version 2. -type BusinessesService Service - -// Get all businesses. -func (s *BusinessesService) List(ctx context.Context, query *Pagination) (*Businesses, *http.Response, error) { - var responseStruct *Businesses - resp, err := s.client.SendRequest(ctx, "GET", "businesses", query, nil, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} - -// Get a business by the given id. -func (s *BusinessesService) Get(ctx context.Context, id uint16) (*GetBusiness, *http.Response, error) { - uri := fmt.Sprintf("businesses/%v", id) - - var responseStruct *GetBusiness - resp, err := s.client.SendRequest(ctx, "GET", uri, nil, nil, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} - -// Get all bridgechains by the given business. -func (s *BusinessesService) Bridgechains(ctx context.Context, id uint16, query *Pagination) (*GetBusinessBridgechains, *http.Response, error) { - uri := fmt.Sprintf("businesses/%v/bridgechains", id) - - var responseStruct *GetBusinessBridgechains - resp, err := s.client.SendRequest(ctx, "GET", uri, query, nil, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} - -// Filter all businesses by the given criteria. -func (s *BusinessesService) Search(ctx context.Context, query *Pagination, body *BusinessesSearchRequest) (*Businesses, *http.Response, error) { - var responseStruct *Businesses - resp, err := s.client.SendRequest(ctx, "POST", "businesses/search", query, body, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} diff --git a/client/businesses_requests.go b/client/businesses_requests.go deleted file mode 100644 index 399d6ed..0000000 --- a/client/businesses_requests.go +++ /dev/null @@ -1,16 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -type BusinessesSearchRequest struct { - BusinessId uint16 `json:"businessId,omitempty"` - Name string `json:"name,omitempty"` - Website string `json:"website,omitempty"` - Vat string `json:"vat,omitempty"` - Repository string `json:"repository,omitempty"` -} diff --git a/client/businesses_responses.go b/client/businesses_responses.go deleted file mode 100644 index 3e51546..0000000 --- a/client/businesses_responses.go +++ /dev/null @@ -1,30 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -type Business struct { - BusinessId uint16 `json:"businessId,omitempty"` - Name string `json:"name,omitempty"` - Website string `json:"website,omitempty"` - Vat string `json:"vat,omitempty"` - Repository string `json:"repository,omitempty"` -} - -type Businesses struct { - Meta Meta `json:"meta,omitempty"` - Data []Business `json:"data,omitempty"` -} - -type GetBusiness struct { - Data Business `json:"data,omitempty"` -} - -type GetBusinessBridgechains struct { - Meta Meta `json:"meta,omitempty"` - Data []Bridgechain `json:"data,omitempty"` -} diff --git a/client/businesses_test.go b/client/businesses_test.go deleted file mode 100644 index 3e166c8..0000000 --- a/client/businesses_test.go +++ /dev/null @@ -1,225 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -import ( - "context" - "fmt" - "net/http" - "testing" -) - -// Get all businesses. -func TestBusinessesService_List(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/businesses", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "GET") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/businesses?page=1&limit=1", - "first": "/api/businesses?page=1&limit=1", - "last": "/api/businesses?page=1&limit=1" - }, - "data": [ - { - "businessId": 1, - "name": "dummyName", - "website": "http://dummy.website", - "vat": "dummyVat", - "repository": "dummyRepository" - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - responseStruct, response, err := client.Businesses.List(context.Background(), query) - testGeneralError(t, "Businesses.List", err) - testResponseUrl(t, "Businesses.List", response, "/api/businesses") - testResponseStruct(t, "Businesses.List", responseStruct, &Businesses{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/businesses?page=1&limit=1", - First: "/api/businesses?page=1&limit=1", - Last: "/api/businesses?page=1&limit=1", - }, - Data: []Business{{ - BusinessId: 1, - Name: "dummyName", - Website: "http://dummy.website", - Vat: "dummyVat", - Repository: "dummyRepository", - }}, - }) -} - -// Get a business by the given id -func TestBusinessesService_Get(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/businesses/1", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "GET") - fmt.Fprint(writer, - `{ - "data": { - "businessId": 1, - "name": "dummyName", - "website": "http://dummy.website", - "vat": "dummyVat", - "repository": "dummyRepository" - } - }`) - }) - - responseStruct, response, err := client.Businesses.Get(context.Background(), 1) - testGeneralError(t, "Businesses.Get", err) - testResponseUrl(t, "Businesses.Get", response, "/businesses/1") - testResponseStruct(t, "Businesses.Get", responseStruct, &GetBusiness{ - Data: Business{ - BusinessId: 1, - Name: "dummyName", - Website: "http://dummy.website", - Vat: "dummyVat", - Repository: "dummyRepository", - }, - }) -} - -// Get all bridgechains by the given business. -func TestBusinessesService_Bridgechains(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/businesses/1/bridgechains", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "GET") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/businesses/1/bridgechains?page=1&limit=1", - "first": "/api/businesses/1/bridgechains?page=1&limit=1", - "last": "/api/businesses/1/bridgechains?page=1&limit=1" - }, - "data": [ - { - "bridgechainId": 1, - "businessId": 1, - "name": "dummyName", - "seedNodes": [ - "1.1.1.1", - "1.1.1.2" - ], - "genesisHash": "dummyGenesisHash", - "bridgechainRepository": "dummyBridgechainRepository" - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - responseStruct, response, err := client.Businesses.Bridgechains(context.Background(), 1, query) - testGeneralError(t, "Businesses.Bridgechains", err) - testResponseUrl(t, "Businesses.Bridgechains", response, "/api/businesses/1/bridgechains") - testResponseStruct(t, "Businesses.Bridgechains", responseStruct, &GetBusinessBridgechains{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/businesses/1/bridgechains?page=1&limit=1", - First: "/api/businesses/1/bridgechains?page=1&limit=1", - Last: "/api/businesses/1/bridgechains?page=1&limit=1", - }, - Data: []Bridgechain{{ - BridgechainId: 1, - BusinessId: 1, - Name: "dummyName", - SeedNodes: []string{ - "1.1.1.1", - "1.1.1.2", - }, - GenesisHash: "dummyGenesisHash", - BridgechainRepository: "dummyBridgechainRepository", - }}, - }) -} - -// Filter all businesses by the given criteria. -func TestBusinessesService_Search(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/businesses/search", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "POST") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/businesses/search?page=1&limit=1", - "first": "/api/businesses/search?page=1&limit=1", - "last": "/api/businesses/search?page=1&limit=1" - }, - "data": [ - { - "businessId": 1, - "name": "dummyName", - "website": "http://dummy.website", - "vat": "dummyVat", - "repository": "dummyRepository" - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - body := &BusinessesSearchRequest{BusinessId: 1} - responseStruct, response, err := client.Businesses.Search(context.Background(), query, body) - testGeneralError(t, "Businesses.Search", err) - testResponseUrl(t, "Businesses.Search", response, "/api/businesses/search") - testResponseStruct(t, "Businesses.Search", responseStruct, &Businesses{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/businesses/search?page=1&limit=1", - First: "/api/businesses/search?page=1&limit=1", - Last: "/api/businesses/search?page=1&limit=1", - }, - Data: []Business{{ - BusinessId: 1, - Name: "dummyName", - Website: "http://dummy.website", - Vat: "dummyVat", - Repository: "dummyRepository", - }}, - }) -} diff --git a/client/client.go b/client/client.go index eb9dfdd..11e3923 100644 --- a/client/client.go +++ b/client/client.go @@ -32,8 +32,6 @@ type Client struct { common Service Blocks *BlocksService - Bridgechains *BridgechainsService - Businesses *BusinessesService Delegates *DelegatesService Locks *LocksService Node *NodeService @@ -59,8 +57,6 @@ func NewClient(httpClient *http.Client) *Client { c.common.client = c c.Blocks = (*BlocksService)(&c.common) - c.Bridgechains = (*BridgechainsService)(&c.common) - c.Businesses = (*BusinessesService)(&c.common) c.Delegates = (*DelegatesService)(&c.common) c.Locks = (*LocksService)(&c.common) c.Node = (*NodeService)(&c.common) diff --git a/client/locks.go b/client/locks.go index 1b01bf4..84d53cc 100644 --- a/client/locks.go +++ b/client/locks.go @@ -43,18 +43,6 @@ func (s *LocksService) Get(ctx context.Context, id string) (*GetLock, *http.Resp return responseStruct, resp, err } -// Filter all locks by the given criteria. -func (s *LocksService) Search(ctx context.Context, query *Pagination, body *LocksSearchRequest) (*Locks, *http.Response, error) { - var responseStruct *Locks - resp, err := s.client.SendRequest(ctx, "POST", "locks/search", query, body, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} - // Retrieve transactions by the given lock ids. func (s *LocksService) Unlocked(ctx context.Context, query *Pagination, body *LocksUnlockedRequest) (*Transactions, *http.Response, error) { var responseStruct *Transactions diff --git a/client/locks_requests.go b/client/locks_requests.go index 312a76b..9eb85d3 100644 --- a/client/locks_requests.go +++ b/client/locks_requests.go @@ -9,17 +9,4 @@ package client type LocksUnlockedRequest struct { Ids []string `json:"ids,omitempty"` -} - -type LocksSearchRequest struct { - LockId string `json:"lockId,omitempty"` - Amount *FromTo `json:"amount,omitempty"` - SecretHash string `json:"secretHash,omitempty"` - SenderPublicKey string `json:"senderPublicKey,omitempty"` - RecipientId string `json:"recipientId,omitempty"` - Timestamp *FromTo `json:"timestamp,omitempty"` - ExpirationType byte `json:"expirationType,omitempty"` - ExpirationValue *FromTo `json:"expirationValue,omitempty"` - VendorField string `json:"vendorField,omitempty"` - IsExpired bool `json:"isExpired,omitempty"` -} +} \ No newline at end of file diff --git a/client/locks_test.go b/client/locks_test.go index f1c69c0..b630e28 100644 --- a/client/locks_test.go +++ b/client/locks_test.go @@ -139,81 +139,6 @@ func TestLocksService_Get(t *testing.T) { }) } -// Filter all locks by the given criteria. -func TestLocksService_Search(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/locks/search", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "POST") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/locks/search?page=1&limit=1", - "first": "/api/locks/search?page=1&limit=1", - "last": "/api/locks/search?page=1&limit=1" - }, - "data": [ - { - "lockId": "dummyLockId", - "amount": "1", - "secretHash": "dummySecretHash", - "senderPublicKey": "dummySenderPublicKey", - "recipientId": "dummyRecipientId", - "timestamp": { - "epoch": 81911280, - "unix": 1572012480, - "human": "2019-10-25T14:08:00.000Z" - }, - "expirationType": 2, - "expirationValue": 6000000, - "vendorField": "dummyVendorField", - "isExpired": false - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - body := &LocksSearchRequest{LockId: "dummyLockId"} - responseStruct, response, err := client.Locks.Search(context.Background(), query, body) - testGeneralError(t, "Locks.Search", err) - testResponseUrl(t, "Locks.Search", response, "/api/locks/search") - testResponseStruct(t, "Locks.Search", responseStruct, &Locks{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/locks/search?page=1&limit=1", - First: "/api/locks/search?page=1&limit=1", - Last: "/api/locks/search?page=1&limit=1", - }, - Data: []Lock{{ - LockId: "dummyLockId", - Amount: 1, - SecretHash: "dummySecretHash", - SenderPublicKey: "dummySenderPublicKey", - RecipientId: "dummyRecipientId", - Timestamp: Timestamp{ - Epoch: 81911280, - Unix: 1572012480, - Human: "2019-10-25T14:08:00.000Z", - }, - ExpirationType: 2, - ExpirationValue: 6000000, - VendorField: "dummyVendorField", - IsExpired: false, - }}, - }) -} - // Retrieve transactions by the given lock ids. func TestLocksService_Unlocked(t *testing.T) { client, mux, _, teardown := setupTest() diff --git a/client/transactions.go b/client/transactions.go index df076bc..a4888e2 100644 --- a/client/transactions.go +++ b/client/transactions.go @@ -81,18 +81,6 @@ func (s *TransactionsService) GetUnconfirmed(ctx context.Context, id string) (*G return responseStruct, resp, err } -// Filter all transactions by the given criteria. -func (s *TransactionsService) Search(ctx context.Context, query *Pagination, body *TransactionsSearchRequest) (*Transactions, *http.Response, error) { - var responseStruct *Transactions - resp, err := s.client.SendRequest(ctx, "POST", "transactions/search", query, body, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} - // Get a list of valid transaction types. func (s *TransactionsService) Types(ctx context.Context) (*TransactionTypes, *http.Response, error) { var responseStruct *TransactionTypes diff --git a/client/transactions_requests.go b/client/transactions_requests.go index d7bc93a..de95e76 100644 --- a/client/transactions_requests.go +++ b/client/transactions_requests.go @@ -10,19 +10,3 @@ package client type CreateTransactionRequest struct { Transactions []Transaction `json:"transactions,omitempty"` } - -type TransactionsSearchRequest struct { - OrderBy string `json:"orderBy,omitempty"` - Id string `json:"id,omitempty"` - SenderId string `json:"senderId,omitempty"` - BlockId string `json:"blockId,omitempty"` - Type byte `json:"type,omitempty"` - TypeGroup uint16 `json:"type,omitempty"` - Version byte `json:"version,omitempty"` - SenderPublicKey string `json:"senderPublicKey,omitempty"` - RecipientId string `json:"recipientId,omitempty"` - Timestamp *FromTo `json:"timestamp,omitempty"` - Amount *FromTo `json:"amount,omitempty"` - Fee *FromTo `json:"fee,omitempty"` - VendorFieldHex string `json:"vendorFieldHex,omitempty"` -} diff --git a/client/transactions_test.go b/client/transactions_test.go index 31db9a3..db74194 100644 --- a/client/transactions_test.go +++ b/client/transactions_test.go @@ -353,89 +353,6 @@ func TestTransactionsService_GetUnconfirmed(t *testing.T) { }) } -// Filter all transactions by the given criteria. -func TestTransactionsService_Search(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/transactions/search", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "POST") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/transactions/search?page=1&limit=1", - "first": "/api/transactions/search?page=1&limit=1", - "last": "/api/transactions/search?page=1&limit=1" - }, - "data": [ - { - "id": "dummy", - "blockId": "dummy", - "type": 0, - "typeGroup": 1, - "amount": "10000000", - "fee": "10000000", - "sender": "dummy", - "senderPublicKey": "dummy", - "recipient": "dummy", - "signature": "dummy", - "vendorField": "dummy", - "confirmations": 10, - "timestamp": { - "epoch": 40505460, - "unix": 1530606660, - "human": "2018-07-03T08:31:00Z" - }, - "nonce": "1" - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - body := &TransactionsSearchRequest{Id: "dummy"} - responseStruct, response, err := client.Transactions.Search(context.Background(), query, body) - testGeneralError(t, "Transactions.Search", err) - testResponseUrl(t, "Transactions.Search", response, "/api/transactions/search") - testResponseStruct(t, "Transactions.Search", responseStruct, &Transactions{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/transactions/search?page=1&limit=1", - First: "/api/transactions/search?page=1&limit=1", - Last: "/api/transactions/search?page=1&limit=1", - }, - Data: []Transaction{{ - Id: "dummy", - BlockId: "dummy", - Type: 0, - TypeGroup: 1, - Amount: 10000000, - Fee: 10000000, - Sender: "dummy", - SenderPublicKey: "dummy", - Recipient: "dummy", - Signature: "dummy", - VendorField: "dummy", - Confirmations: 10, - Timestamp: Timestamp{ - Epoch: 40505460, - Unix: 1530606660, - Human: "2018-07-03T08:31:00Z", - }, - Nonce: 1, - }}, - }) -} - // Get a list of valid transaction types. func TestTransactionsService_Types(t *testing.T) { client, mux, _, teardown := setupTest() diff --git a/client/wallets.go b/client/wallets.go index 8a4d697..83963d2 100644 --- a/client/wallets.go +++ b/client/wallets.go @@ -124,15 +124,3 @@ func (s *WalletsService) Votes(ctx context.Context, id string, query *Pagination return responseStruct, resp, err } - -// Filter all wallets by the given criteria. -func (s *WalletsService) Search(ctx context.Context, query *Pagination, body *WalletsSearchRequest) (*Wallets, *http.Response, error) { - var responseStruct *Wallets - resp, err := s.client.SendRequest(ctx, "POST", "wallets/search", query, body, &responseStruct) - - if err != nil { - return nil, resp, err - } - - return responseStruct, resp, err -} diff --git a/client/wallets_requests.go b/client/wallets_requests.go deleted file mode 100644 index 0b1423a..0000000 --- a/client/wallets_requests.go +++ /dev/null @@ -1,21 +0,0 @@ -// This file is part of Ark Go Client. -// -// (c) Ark Ecosystem -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -package client - -type WalletsSearchRequest struct { - OrderBy string `json:"orderBy,omitempty"` - Address string `json:"address,omitempty"` - PublicKey string `json:"publicKey,omitempty"` - SecondPublicKey string `json:"secondPublicKey,omitempty"` - Vote string `json:"vote,omitempty"` - Username string `json:"username,omitempty"` - ProducedBlocks uint32 `json:"producedBlocks,omitempty"` - MissedBlocks uint32 `json:"missedBlocks,omitempty"` - Balance *FromTo `json:"balance ,omitempty"` - VoteBalance *FromTo `json:"voteBalance ,omitempty"` -} diff --git a/client/wallets_test.go b/client/wallets_test.go index 9b2790a..0682f7a 100644 --- a/client/wallets_test.go +++ b/client/wallets_test.go @@ -566,60 +566,3 @@ func TestWalletsService_Votes(t *testing.T) { }}, }) } - -// Filter all wallets by the given criteria. -func TestWalletsService_Search(t *testing.T) { - client, mux, _, teardown := setupTest() - defer teardown() - - mux.HandleFunc("/wallets/search", func(writer http.ResponseWriter, request *http.Request) { - testMethod(t, request, "POST") - fmt.Fprint(writer, - `{ - "meta": { - "count": 1, - "pageCount": 1, - "totalCount": 1, - "next": null, - "previous": null, - "self": "/api/wallets/search?page=1&limit=1", - "first": "/api/wallets/search?page=1&limit=1", - "last": "/api/wallets/search?page=1&limit=1" - }, - "data": [ - { - "address": "dummy", - "publicKey": "dummy", - "nonce": "1", - "balance": "1000000000", - "isDelegate": false - } - ] - }`) - }) - - query := &Pagination{Limit: 1} - body := &WalletsSearchRequest{Address: "dummy"} - responseStruct, response, err := client.Wallets.Search(context.Background(), query, body) - testGeneralError(t, "Wallets.Search", err) - testResponseUrl(t, "Wallets.Search", response, "/api/wallets/search") - testResponseStruct(t, "Wallets.Search", responseStruct, &Wallets{ - Meta: Meta{ - Count: 1, - PageCount: 1, - TotalCount: 1, - Next: "", - Previous: "", - Self: "/api/wallets/search?page=1&limit=1", - First: "/api/wallets/search?page=1&limit=1", - Last: "/api/wallets/search?page=1&limit=1", - }, - Data: []Wallet{{ - Address: "dummy", - PublicKey: "dummy", - Nonce: 1, - Balance: 1000000000, - IsDelegate: false, - }}, - }) -}