Skip to content

Commit

Permalink
Merge pull request #4 from apivideo/fix/deep-objects-params-in-query
Browse files Browse the repository at this point in the history
Handle deep objects params in query
  • Loading branch information
bot-api-video authored Jun 9, 2021
2 parents f179d66 + 3e4f2b8 commit f5aba2b
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 43 deletions.
23 changes: 17 additions & 6 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ paths:
type: string
type: object
style: deepObject
x-key-value-serialized-param: true
x-is-deep-object: true
- description: If you described a video with a term or sentence, you can add
it here to return videos containing this string.
example: New Zealand
Expand Down Expand Up @@ -2815,17 +2815,17 @@ paths:
style: form
- description: Metadata and Dynamic Metadata filter. Send an array of key value
pairs you want to filter sessios with.
example: '[{"key": "Author", "value": "John Doe"}, {"key": "Format", "value":
"Tutorial"}]'
example: metadata[Author]=John Doe&metadata[Format]=Tutorial
explode: true
in: query
name: metadata
required: false
schema:
items:
additionalProperties:
type: string
type: array
style: form
type: object
style: deepObject
x-is-deep-object: true
- description: 'Choose the number of search results to return per page. Minimum
value: 1'
example: 2
Expand Down Expand Up @@ -5291,6 +5291,15 @@ components:
description: When the video session ended, presented in ISO-8601 format.
format: date-time
type: string
metadata:
description: A list of key value pairs that you use to provide metadata
for your video. These pairs can be made dynamic, allowing you to segment
your audience. You can also just use the pairs as another way to tag and
categorize your videos.
example: '[{"key": "Author", "value": "John Doe"}]'
items:
$ref: '#/components/schemas/metadata'
type: array
title: VideoSessionSession
type: object
video-session-location:
Expand All @@ -5303,6 +5312,7 @@ components:
city:
description: The city of the viewer.
example: Paris
nullable: true
type: string
title: VideoSessionLocation
type: object
Expand All @@ -5311,6 +5321,7 @@ components:
url:
description: The link the viewer used to reach the video session.
example: https://api.video
nullable: true
type: string
medium:
description: How they arrived at the site, for example organic or paid.
Expand Down
1 change: 0 additions & 1 deletion api_player_themes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ func TestPlayers_Update(t *testing.T) {
if err != nil {
t.Fatalf("decode json: %v", err)
}
fmt.Println(v)
if !reflect.DeepEqual(v, expectedBody) {
t.Errorf("Request body\n got=%#v\n want=%#v", v, expectedBody)
}
Expand Down
16 changes: 6 additions & 10 deletions api_raw_statistics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion api_videos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ func TestVideos_List(t *testing.T) {
"metadata[key]": []string{"value"},
"metadata[key2]": []string{"value2"},
}
fmt.Println(r.URL.Query())
if !reflect.DeepEqual(r.URL.Query(), expectedQuery) {
t.Errorf("Request querystring\n got=%#v\nwant=%#v", r.URL.Query(), expectedQuery)
}
Expand Down
5 changes: 2 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (c *Client) prepareRequest(

req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "api.video client (GO; v:0.0.3; )")
req.Header.Set("User-Agent", "api.video client (GO; v:0.0.4; )")

for headerName := range headerParams {
req.Header.Set(headerName, headerParams[headerName])
Expand Down Expand Up @@ -269,7 +269,6 @@ func (c *Client) prepareRangeRequests(

if fileSize > c.chunkSize && c.chunkSize != 0 {
ranges := fmt.Sprintf("bytes %d-%d/%d", startByte, (startByte+bytesread)-1, fileSize)
fmt.Println(ranges)
req.Header.Set("Content-Range", ranges)
startByte = startByte + bytesread
}
Expand Down Expand Up @@ -375,7 +374,7 @@ func (c *Client) auth(req *http.Request) (*http.Request, error) {

req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "api.video client (GO; v:0.0.3; )")
req.Header.Set("User-Agent", "api.video client (GO; v:0.0.4; )")

resp, err := c.httpClient.Do(req)

Expand Down
4 changes: 2 additions & 2 deletions docs/RawStatistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func main() {

req.VideoId("vi4k0jvEUuaTdRAEjQ4Prklg") // string | The unique identifier for the video you want to retrieve session information for.
req.Period("period_example") // string | Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15
req.Metadata([]string{"Inner_example"}) // []string | Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with.
req.Metadata(map[string]string{"key": "Inner_example"}) // map[string]string | Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with.
req.CurrentPage(int32(2)) // int32 | Choose the number of search results to return per page. Minimum value: 1 (default to 1)
req.PageSize(int32(30)) // int32 | Results per page. Allowed values 1-100, default is 25. (default to 25)

Expand Down Expand Up @@ -214,7 +214,7 @@ Name | Type | Description | Notes
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**period** | **string** | Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15 |
**metadata** | **[]string** | Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with. |
**metadata** | **map[string]string** | Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with. |
**currentPage** | **int32** | Choose the number of search results to return per page. Minimum value: 1 | [default to 1]
**pageSize** | **int32** | Results per page. Allowed values 1-100, default is 25. | [default to 25]

Expand Down
12 changes: 11 additions & 1 deletion docs/VideoSessionLocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Country** | Pointer to **string** | The country of the viewer. | [optional]
**City** | Pointer to **string** | The city of the viewer. | [optional]
**City** | Pointer to **NullableString** | The city of the viewer. | [optional]

## Methods

Expand Down Expand Up @@ -76,6 +76,16 @@ SetCity sets City field to given value.

HasCity returns a boolean if a field has been set.

### SetCityNil

`func (o *VideoSessionLocation) SetCityNil(b bool)`

SetCityNil sets the value for City to be an explicit nil

### UnsetCity
`func (o *VideoSessionLocation) UnsetCity()`

UnsetCity ensures that no value is present for City, not even an explicit nil

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
12 changes: 11 additions & 1 deletion docs/VideoSessionReferrer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Url** | Pointer to **string** | The link the viewer used to reach the video session. | [optional]
**Url** | Pointer to **NullableString** | The link the viewer used to reach the video session. | [optional]
**Medium** | Pointer to **string** | How they arrived at the site, for example organic or paid. Organic meaning they found it themselves and paid meaning they followed a link from an advertisement. | [optional]
**Source** | Pointer to **string** | The source the referrer came from to the video session. For example if they searched through google to find the stream. | [optional]
**SearchTerm** | Pointer to **string** | The search term they typed to arrive at the video session. | [optional]
Expand Down Expand Up @@ -53,6 +53,16 @@ SetUrl sets Url field to given value.

HasUrl returns a boolean if a field has been set.

### SetUrlNil

`func (o *VideoSessionReferrer) SetUrlNil(b bool)`

SetUrlNil sets the value for Url to be an explicit nil

### UnsetUrl
`func (o *VideoSessionReferrer) UnsetUrl()`

UnsetUrl ensures that no value is present for Url, not even an explicit nil
### GetMedium

`func (o *VideoSessionReferrer) GetMedium() string`
Expand Down
26 changes: 26 additions & 0 deletions docs/VideoSessionSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Name | Type | Description | Notes
**SessionId** | Pointer to **string** | The unique identifier for the session that you can use to track what happens during it. | [optional]
**LoadedAt** | Pointer to **string** | When the video session started, presented in ISO-8601 format. | [optional]
**EndedAt** | Pointer to **string** | When the video session ended, presented in ISO-8601 format. | [optional]
**Metadata** | Pointer to [**[]Metadata**](Metadata.md) | A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. You can also just use the pairs as another way to tag and categorize your videos. | [optional]

## Methods

Expand Down Expand Up @@ -102,6 +103,31 @@ SetEndedAt sets EndedAt field to given value.

HasEndedAt returns a boolean if a field has been set.

### GetMetadata

`func (o *VideoSessionSession) GetMetadata() []Metadata`

GetMetadata returns the Metadata field if non-nil, zero value otherwise.

### GetMetadataOk

`func (o *VideoSessionSession) GetMetadataOk() (*[]Metadata, bool)`

GetMetadataOk returns a tuple with the Metadata field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetMetadata

`func (o *VideoSessionSession) SetMetadata(v []Metadata)`

SetMetadata sets Metadata field to given value.

### HasMetadata

`func (o *VideoSessionSession) HasMetadata() bool`

HasMetadata returns a boolean if a field has been set.


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
46 changes: 46 additions & 0 deletions integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package apivideosdk

import (
"os"
"testing"
)

func IntegrationTests(t *testing.T) {
client := ClientBuilder(os.Getenv("API_KEY")).Build()

// create a video
payload := VideoCreationPayload{
Title: "go client test",
}
video, err := client.Videos.Create(payload)

if err != nil {
t.Errorf("Videos.Create error: %v", err)
}

// upload a video file
videoFile, err := os.Open("sample.mp4")
_, err = client.Videos.UploadFile(video.VideoId, videoFile)

if err != nil {
t.Errorf("Videos.Delete error: %v", err)
}

// list video sessions
metadata := map[string]string{"key": "value", "key2": "value2"}
listVideoSessionPayload := RawStatisticsApiListVideoSessionsRequest{
metadata: &metadata,
}
_, err = client.RawStatistics.ListVideoSessions(video.VideoId, listVideoSessionPayload)

if err != nil {
t.Errorf("RawStatistics.ListVideoSessions error: %v", err)
}

// delete the video
err = client.Videos.Delete(video.VideoId)

if err != nil {
t.Errorf("Videos.Delete error: %v", err)
}
}
29 changes: 20 additions & 9 deletions model_video_session_location.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f5aba2b

Please sign in to comment.