-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
117 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
package broker | ||
|
||
type Broker struct { | ||
Name string | ||
Title string | ||
Url string | ||
Logo string | ||
} | ||
|
||
type TBroker string | ||
type EnumBroker string | ||
|
||
const ( | ||
Garanti TBroker = "garanti" | ||
NCM TBroker = "ncm" | ||
Garanti EnumBroker = "garanti" | ||
NCM EnumBroker = "ncm" | ||
) | ||
|
||
func (b TBroker) String() string { | ||
return string(b) | ||
func (t EnumBroker) String() string { | ||
return string(t) | ||
} | ||
|
||
type Info struct { | ||
Enum EnumBroker | ||
Name string | ||
Title string | ||
Url string | ||
Logo string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package module | ||
|
||
import ( | ||
"errors" | ||
"github.com/guneyin/gobist-broker/broker" | ||
"github.com/guneyin/gobist-broker/broker/garanti" | ||
"github.com/guneyin/gobist-broker/broker/ncm" | ||
"github.com/guneyin/gobist-broker/entity" | ||
"sync" | ||
) | ||
|
||
var ( | ||
_ Broker = (*garanti.Garanti)(nil) | ||
_ Broker = (*ncm.NCM)(nil) | ||
) | ||
|
||
type Broker interface { | ||
Info() broker.Info | ||
Parse(content []byte) (*entity.Transactions, error) | ||
} | ||
|
||
type Brokers map[broker.EnumBroker]Broker | ||
|
||
var brokers Brokers | ||
|
||
func init() { | ||
once := &sync.Once{} | ||
|
||
once.Do(func() { | ||
brokers = Brokers{ | ||
broker.Garanti: garanti.New(), | ||
broker.NCM: ncm.New(), | ||
} | ||
}) | ||
} | ||
|
||
func GetBrokers() Brokers { | ||
return brokers | ||
} | ||
|
||
func GetBroker(b broker.EnumBroker) Broker { | ||
return brokers[b] | ||
} | ||
|
||
func GetBrokerByName(name string) (Broker, error) { | ||
if ok := broker.EnumBroker(name); ok == "" { | ||
return nil, errors.New("UNSPPORTED_BROKER") | ||
} | ||
|
||
b := broker.EnumBroker(name) | ||
|
||
return GetBroker(b), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.