add blocking feature to certain SDK calls

This commit is contained in:
Niko Storni 2019-06-11 18:40:48 +02:00
parent b444d284c6
commit 963177cd4c
2 changed files with 19 additions and 9 deletions

View file

@ -259,11 +259,13 @@ func (d *Client) ChannelCreate(name string, bid float64, options ChannelCreateOp
FilePath string `json:"file_path,omitempty"`
IncludeProtoBuf bool `json:"include_protobuf"`
ChannelCreateOptions `json:",flatten"`
Blocking bool `json:"blocking"`
}{
Name: name,
Bid: fmt.Sprintf("%.6f", bid),
IncludeProtoBuf: true,
ChannelCreateOptions: options,
Blocking: true,
}
structs.DefaultTagName = "json"
return response, d.call(response, "channel_create", structs.Map(args))
@ -284,10 +286,12 @@ func (d *Client) ChannelUpdate(claimID string, options ChannelUpdateOptions) (*T
ClaimID string `json:"claim_id"`
IncludeProtoBuf bool `json:"include_protobuf"`
*ChannelUpdateOptions `json:",flatten"`
Blocking bool `json:"blocking"`
}{
ClaimID: claimID,
IncludeProtoBuf: true,
ChannelUpdateOptions: &options,
Blocking: true,
}
structs.DefaultTagName = "json"
return response, d.call(response, "channel_update", structs.Map(args))
@ -319,12 +323,14 @@ func (d *Client) StreamCreate(name, filePath string, bid float64, options Stream
FilePath string `json:"file_path,omitempty"`
FileSize *string `json:"file_size,omitempty"`
IncludeProtoBuf bool `json:"include_protobuf"`
Blocking bool `json:"blocking"`
*StreamCreateOptions `json:",flatten"`
}{
Name: name,
FilePath: filePath,
Bid: fmt.Sprintf("%.6f", bid),
IncludeProtoBuf: true,
Blocking: true,
StreamCreateOptions: &options,
}
structs.DefaultTagName = "json"
@ -338,6 +344,7 @@ func (d *Client) StreamAbandon(txID string, nOut uint64, accountID *string, bloc
"nout": nOut,
"account_id": accountID,
"include_protobuf": true,
"blocking": true,
})
if err != nil {
return nil, err
@ -363,10 +370,12 @@ func (d *Client) StreamUpdate(claimID string, options StreamUpdateOptions) (*Tra
ClaimID string `json:"claim_id"`
IncludeProtoBuf bool `json:"include_protobuf"`
*StreamUpdateOptions `json:",flatten"`
Blocking bool `json:"blocking"`
}{
ClaimID: claimID,
IncludeProtoBuf: true,
StreamUpdateOptions: &options,
Blocking: true,
}
structs.DefaultTagName = "json"
return response, d.call(response, "stream_update", structs.Map(args))
@ -379,6 +388,7 @@ func (d *Client) ChannelAbandon(txID string, nOut uint64, accountID *string, blo
"nout": nOut,
"account_id": accountID,
"include_protobuf": true,
"blocking": true,
})
if err != nil {
return nil, err

View file

@ -111,8 +111,8 @@ func TestClient_StreamCreate(t *testing.T) {
address := string(*addressResponse)
got, err := d.StreamCreate("test"+fmt.Sprintf("%d", time.Now().Unix()), "/home/niko/Downloads/IMG_20171012_205120.jpg", 14.37, StreamCreateOptions{
ClaimCreateOptions: ClaimCreateOptions{
Title: "This is a Test Title" + fmt.Sprintf("%d", time.Now().Unix()),
Description: "My Special Description",
Title: util.PtrToString("This is a Test Title" + fmt.Sprintf("%d", time.Now().Unix())),
Description: util.PtrToString("My Special Description"),
Tags: []string{"nsfw", "test"},
Languages: []string{"en-US", "fr-CH"},
Locations: []Location{{
@ -142,7 +142,7 @@ func TestClient_StreamCreate(t *testing.T) {
Preview: nil,
AllowDuplicateName: nil,
ChannelName: nil,
ChannelID: util.PtrToString("253ca42da47ad8a430e18d52860cb499c50eff25"),
ChannelID: util.PtrToString("dd0b559b4f17a7af984f173efb5438534eb6ab27"),
ChannelAccountID: nil,
})
if err != nil {
@ -156,8 +156,8 @@ func TestClient_ChannelCreate(t *testing.T) {
d := NewClient("")
got, err := d.ChannelCreate("@Test"+fmt.Sprintf("%d", time.Now().Unix()), 13.37, ChannelCreateOptions{
ClaimCreateOptions: ClaimCreateOptions{
Title: "Mess with the channels",
Description: "And you'll get what you deserve",
Title: util.PtrToString("Mess with the channels"),
Description: util.PtrToString("And you'll get what you deserve"),
Tags: []string{"we", "got", "tags"},
Languages: []string{"en-US"},
Locations: []Location{{
@ -186,8 +186,8 @@ func TestClient_ChannelUpdate(t *testing.T) {
ClearTags: util.PtrToBool(true),
ChannelCreateOptions: ChannelCreateOptions{
ClaimCreateOptions: ClaimCreateOptions{
Title: "Mess with the channels",
Description: "And you'll get what you deserve",
Title: util.PtrToString("Mess with the channels"),
Description: util.PtrToString("And you'll get what you deserve"),
Tags: []string{"we", "got", "more", "tags"},
Languages: []string{"en-US"},
Locations: []Location{{
@ -213,8 +213,8 @@ func TestClient_ChannelAbandon(t *testing.T) {
channelName := "@TestToDelete" + fmt.Sprintf("%d", time.Now().Unix())
channelResponse, err := d.ChannelCreate(channelName, 13.37, ChannelCreateOptions{
ClaimCreateOptions: ClaimCreateOptions{
Title: "Mess with the channels",
Description: "And you'll get what you deserve",
Title: util.PtrToString("Mess with the channels"),
Description: util.PtrToString("And you'll get what you deserve"),
Tags: []string{"we", "got", "tags"},
Languages: []string{"en-US"},
Locations: []Location{{