Skip to content

Commit

Permalink
feat: regenerate types from spec (#8)
Browse files Browse the repository at this point in the history
* feat(sdk/go)!: regenerate types from spec (#2841)

GitOrigin-RevId: 0417ad8f1d999a8f1e737f64e6c36dc7a35e11e6

* keep dependency
  • Loading branch information
marcusolsson authored Nov 23, 2023
1 parent 9a30872 commit 825a7be
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 174 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func main() {

client := assemblyai.NewClient(apiKey)

opts := &assemblyai.TranscriptSubmitOptions{
opts := &assemblyai.TranscriptParams{
EntityDetection: assemblyai.Bool(true),
}

Expand All @@ -154,7 +154,7 @@ func main() {

for _, entity := range transcript.Entities {
log.Println(*entity.Text)
log.Println(*entity.Type)
log.Println(entity.EntityType)
log.Printf("Timestamp: %v - %v", *entity.Start, *entity.End)
}
}
Expand Down
4 changes: 2 additions & 2 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func TestIntegration(t *testing.T) {

t.Logf("summarizing transcript (%v)...", transcript.ID)

response, err := client.LeMUR.Summarize(ctx, LeMURSummaryParameters{
LeMURBaseParameters: LeMURBaseParameters{
response, err := client.LeMUR.Summarize(ctx, LeMURSummaryParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{ToString(transcript.ID)},
},
})
Expand Down
8 changes: 4 additions & 4 deletions lemur.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type LeMURService struct {
// Question returns answers to free-form questions about one or more transcripts.
//
// https://www.assemblyai.com/docs/Models/lemur#question--answer
func (s *LeMURService) Question(ctx context.Context, params LeMURQuestionAnswerParameters) (LeMURQuestionAnswerResponse, error) {
func (s *LeMURService) Question(ctx context.Context, params LeMURQuestionAnswerParams) (LeMURQuestionAnswerResponse, error) {
var response LeMURQuestionAnswerResponse

req, err := s.client.newJSONRequest("POST", "/lemur/v3/generate/question-answer", params)
Expand All @@ -30,7 +30,7 @@ func (s *LeMURService) Question(ctx context.Context, params LeMURQuestionAnswerP
// Summarize returns a custom summary of a set of transcripts.
//
// https://www.assemblyai.com/docs/Models/lemur#action-items
func (s *LeMURService) Summarize(ctx context.Context, params LeMURSummaryParameters) (LeMURSummaryResponse, error) {
func (s *LeMURService) Summarize(ctx context.Context, params LeMURSummaryParams) (LeMURSummaryResponse, error) {
req, err := s.client.newJSONRequest("POST", "/lemur/v3/generate/summary", params)
if err != nil {
return LeMURSummaryResponse{}, err
Expand All @@ -48,7 +48,7 @@ func (s *LeMURService) Summarize(ctx context.Context, params LeMURSummaryParamet
// ActionItems returns a set of action items based on a set of transcripts.
//
// https://www.assemblyai.com/docs/Models/lemur#action-items
func (s *LeMURService) ActionItems(ctx context.Context, params LeMURActionItemsParameters) (LeMURActionItemsResponse, error) {
func (s *LeMURService) ActionItems(ctx context.Context, params LeMURActionItemsParams) (LeMURActionItemsResponse, error) {
req, err := s.client.newJSONRequest("POST", "/lemur/v3/generate/action-items", params)
if err != nil {
return LeMURActionItemsResponse{}, err
Expand All @@ -66,7 +66,7 @@ func (s *LeMURService) ActionItems(ctx context.Context, params LeMURActionItemsP
// Task lets you submit a custom prompt to LeMUR.
//
// https://www.assemblyai.com/docs/Models/lemur#task
func (s *LeMURService) Task(ctx context.Context, params LeMURTaskParameters) (LeMURTaskResponse, error) {
func (s *LeMURService) Task(ctx context.Context, params LeMURTaskParams) (LeMURTaskResponse, error) {
req, err := s.client.newJSONRequest("POST", "/lemur/v3/generate/task", params)
if err != nil {
return LeMURTaskResponse{}, err
Expand Down
40 changes: 20 additions & 20 deletions lemur_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ func TestLeMUR_Summarize(t *testing.T) {
handler.HandleFunc("/lemur/v3/generate/summary", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")

var body LeMURSummaryParameters
var body LeMURSummaryParams
json.NewDecoder(r.Body).Decode(&body)

want := LeMURSummaryParameters{
LeMURBaseParameters: LeMURBaseParameters{
want := LeMURSummaryParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
}
Expand All @@ -34,8 +34,8 @@ func TestLeMUR_Summarize(t *testing.T) {

ctx := context.Background()

response, err := client.LeMUR.Summarize(ctx, LeMURSummaryParameters{
LeMURBaseParameters: LeMURBaseParameters{
response, err := client.LeMUR.Summarize(ctx, LeMURSummaryParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
})
Expand All @@ -57,11 +57,11 @@ func TestLeMUR_QuestionAnswer(t *testing.T) {
handler.HandleFunc("/lemur/v3/generate/question-answer", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")

var body LeMURQuestionAnswerParameters
var body LeMURQuestionAnswerParams
json.NewDecoder(r.Body).Decode(&body)

want := LeMURQuestionAnswerParameters{
LeMURBaseParameters: LeMURBaseParameters{
want := LeMURQuestionAnswerParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
Questions: []LeMURQuestion{
Expand All @@ -82,8 +82,8 @@ func TestLeMUR_QuestionAnswer(t *testing.T) {
{Question: String("What's causing the wildfires?")},
}

answers, err := client.LeMUR.Question(ctx, LeMURQuestionAnswerParameters{
LeMURBaseParameters: LeMURBaseParameters{
answers, err := client.LeMUR.Question(ctx, LeMURQuestionAnswerParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
Questions: questions,
Expand Down Expand Up @@ -111,11 +111,11 @@ func TestLeMUR_ActionItems(t *testing.T) {
handler.HandleFunc("/lemur/v3/generate/action-items", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")

var body LeMURActionItemsParameters
var body LeMURActionItemsParams
json.NewDecoder(r.Body).Decode(&body)

want := LeMURActionItemsParameters{
LeMURBaseParameters: LeMURBaseParameters{
want := LeMURActionItemsParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
}
Expand All @@ -129,8 +129,8 @@ func TestLeMUR_ActionItems(t *testing.T) {

ctx := context.Background()

response, err := client.LeMUR.ActionItems(ctx, LeMURActionItemsParameters{
LeMURBaseParameters: LeMURBaseParameters{
response, err := client.LeMUR.ActionItems(ctx, LeMURActionItemsParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
})
Expand Down Expand Up @@ -158,11 +158,11 @@ then get into the examples with feedback.
handler.HandleFunc("/lemur/v3/generate/task", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")

var body LeMURTaskParameters
var body LeMURTaskParams
json.NewDecoder(r.Body).Decode(&body)

want := LeMURTaskParameters{
LeMURBaseParameters: LeMURBaseParameters{
want := LeMURTaskParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
Prompt: String(prompt),
Expand All @@ -177,8 +177,8 @@ then get into the examples with feedback.

ctx := context.Background()

response, err := client.LeMUR.Task(ctx, LeMURTaskParameters{
LeMURBaseParameters: LeMURBaseParameters{
response, err := client.LeMUR.Task(ctx, LeMURTaskParams{
LeMURBaseParams: LeMURBaseParams{
TranscriptIDs: []string{"transcript_id"},
},
Prompt: String(prompt),
Expand Down
12 changes: 6 additions & 6 deletions transcript.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ type TranscriptService struct {
// Submit submits an audio file for transcription.
//
// https://www.assemblyai.com/docs/API%20reference/transcript#create-a-transcript
func (s *TranscriptService) Submit(ctx context.Context, audioURL string, opts *CreateTranscriptOptionalParameters) (Transcript, error) {
func (s *TranscriptService) Submit(ctx context.Context, audioURL string, opts *TranscriptOptionalParams) (Transcript, error) {
var transcript Transcript

params := CreateTranscriptParameters{
params := TranscriptParams{
AudioURL: String(audioURL),
}

if opts != nil {
params.CreateTranscriptOptionalParameters = *opts
params.TranscriptOptionalParams = *opts
}

req, err := s.client.newJSONRequest("POST", "/v2/transcript", params)
Expand Down Expand Up @@ -175,7 +175,7 @@ func (s *TranscriptService) GetSubtitles(ctx context.Context, transcriptID strin
// List returns a collection of transcripts based on a filter.
//
// https://www.assemblyai.com/docs/API%20reference/listing_and_deleting#listing-historical-transcripts
func (s *TranscriptService) List(ctx context.Context, options TranscriptListParameters) (TranscriptList, error) {
func (s *TranscriptService) List(ctx context.Context, options ListTranscriptParams) (TranscriptList, error) {
req, err := s.client.newJSONRequest("GET", "/v2/transcript", options)
if err != nil {
return TranscriptList{}, err
Expand Down Expand Up @@ -223,15 +223,15 @@ func (s *TranscriptService) Wait(ctx context.Context, transcriptID string) (Tran
}
}

func (s *TranscriptService) TranscribeFromURL(ctx context.Context, audioURL string, opts *CreateTranscriptOptionalParameters) (Transcript, error) {
func (s *TranscriptService) TranscribeFromURL(ctx context.Context, audioURL string, opts *TranscriptOptionalParams) (Transcript, error) {
transcript, err := s.Submit(ctx, audioURL, opts)
if err != nil {
return transcript, err
}
return s.Wait(ctx, *transcript.ID)
}

func (s *TranscriptService) TranscribeFromReader(ctx context.Context, reader io.Reader, opts *CreateTranscriptOptionalParameters) (Transcript, error) {
func (s *TranscriptService) TranscribeFromReader(ctx context.Context, reader io.Reader, opts *TranscriptOptionalParams) (Transcript, error) {
u, err := s.client.Upload(ctx, reader)
if err != nil {
return Transcript{}, err
Expand Down
6 changes: 3 additions & 3 deletions transcript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func TestTranscripts_Submit(t *testing.T) {
t.Errorf("Request body = %v, want = %v", string(b), wantBody)
}

var body CreateTranscriptParameters
var body TranscriptParams
json.Unmarshal(b, &body)

want := CreateTranscriptParameters{AudioURL: String(fakeAudioURL)}
want := TranscriptParams{AudioURL: String(fakeAudioURL)}

if !cmp.Equal(body, want) {
t.Errorf("Request body = %+v, want = %+v", body, want)
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestTranscripts_List(t *testing.T) {

ctx := context.Background()

results, err := client.Transcripts.List(ctx, TranscriptListParameters{
results, err := client.Transcripts.List(ctx, ListTranscriptParams{
Limit: Int64(2),
})
if err != nil {
Expand Down
Loading

0 comments on commit 825a7be

Please sign in to comment.