Skip to content

Commit

Permalink
Fix create comment function
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmari-h committed Nov 11, 2024
1 parent 443d3b5 commit c2511d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package tapestry
type TapestryClient struct {
tapestryApiBaseUrl string
apiKey string
execution TapestryExecutionType
execution Execution
blockchain string
}

type TapestryExecutionType string
type Execution string

const (
FastUnconfirmed TapestryExecutionType = "FAST_UNCONFIRMED"
QuickSignature TapestryExecutionType = "QUICK_SIGNATURE"
ConfirmedParsed TapestryExecutionType = "CONFIRMED_AND_PARSED"
ExecutionFastUnconfirmed Execution = "FAST_UNCONFIRMED"
ExecutionQuickSignature Execution = "QUICK_SIGNATURE"
ExecutionConfirmedParsed Execution = "CONFIRMED_AND_PARSED"
)

func NewTapestryClient(apiKey string, tapestryApiBaseUrl string, execution TapestryExecutionType, blockchain string) TapestryClient {
func NewTapestryClient(apiKey string, tapestryApiBaseUrl string, execution Execution, blockchain string) TapestryClient {
return TapestryClient{
tapestryApiBaseUrl: tapestryApiBaseUrl,
apiKey: apiKey,
Expand Down
3 changes: 3 additions & 0 deletions comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type UpdateCommentResponse struct {

func (c *TapestryClient) CreateComment(options CreateCommentOptions) (*CreateCommentResponse, error) {
url := fmt.Sprintf("%s/comments?apiKey=%s", c.tapestryApiBaseUrl, c.apiKey)
if options.Properties == nil {
options.Properties = []CommentProperty{}
}
req := CreateCommentRequest{
CreateCommentOptions: options,
Execution: string(c.execution),
Expand Down
8 changes: 4 additions & 4 deletions contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ContentProperty struct {
Value string `json:"value"`
}

type CreateContentRequest struct {
type FindOrCreateContentRequest struct {
ProfileID string `json:"profileId"`
ID string `json:"id,omitempty"`
Properties []ContentProperty `json:"properties"`
Expand Down Expand Up @@ -66,13 +66,13 @@ type SocialCounts struct {
CommentCount int `json:"commentCount"`
}

func (c *TapestryClient) FindOrCreateContent(profileId, id string, content []ContentProperty) (*CreateOrUpdateContentResponse, error) {
func (c *TapestryClient) FindOrCreateContent(profileId, id string, properties []ContentProperty) (*CreateOrUpdateContentResponse, error) {
url := fmt.Sprintf("%s/contents/findOrCreate?apiKey=%s", c.tapestryApiBaseUrl, c.apiKey)

jsonBody, err := json.Marshal(CreateContentRequest{
jsonBody, err := json.Marshal(FindOrCreateContentRequest{
ProfileID: profileId,
ID: id,
Properties: content,
Properties: properties,
})
if err != nil {
return nil, fmt.Errorf("error marshaling request: %w", err)
Expand Down

0 comments on commit c2511d8

Please sign in to comment.