Skip to content

Commit

Permalink
Merge pull request #368 from Fullscreen/update-patch-asset
Browse files Browse the repository at this point in the history
Fix MatchPolicy#update and Asset#update
  • Loading branch information
kangkyu committed Nov 7, 2019
2 parents da4accc + 0ff0dd0 commit d70171d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,12 @@ For more information about changelogs, check
[Keep a Changelog](http://keepachangelog.com) and
[Vandamme](http://tech-angels.github.io/vandamme).


## 0.32.5 - 2019-11-06

* [BUGFIX] Fix `MatchPolicy#update` and `Asset#update` by using `PUT` instead of `PATCH`
* Update `bin/yt` file to keep `yt info` command work

## 0.32.4 - 2019-06-26

* [FEATURE] Add `ownership_effective` method to access asset ownership ("effective") via the asset object.
Expand Down
11 changes: 10 additions & 1 deletion lib/yt/models/asset.rb
Expand Up @@ -17,7 +17,7 @@ def initialize(options = {})

def update(attributes = {})
underscore_keys! attributes
do_patch body: attributes
do_update body: attributes
true
end

Expand Down Expand Up @@ -112,6 +112,15 @@ def patch_params
end
end

# @see https://developers.google.com/youtube/partner/docs/v1/assets/update
def update_params
super.tap do |params|
params[:expected_response] = Net::HTTPOK
params[:path] = "/youtube/partner/v1/assets/#{@id}"
params[:params] = {on_behalf_of_content_owner: @auth.owner_name}
end
end

# @return [Hash] the parameters to submit to YouTube to get an asset.
# @see https://developers.google.com/youtube/partner/docs/v1/assets/get
def get_params
Expand Down
10 changes: 4 additions & 6 deletions lib/yt/models/match_policy.rb
Expand Up @@ -13,16 +13,14 @@ def initialize(options = {})

def update(attributes = {})
underscore_keys! attributes
do_patch body: attributes.slice(:policy_id)
do_update body: attributes.slice(:policy_id)
true
end

private

# @return [Hash] the parameters to submit to YouTube to patch an asset
# match policy.
# @see https://developers.google.com/youtube/partner/docs/v1/assetMatchPolicy/patch
def patch_params
# @see https://developers.google.com/youtube/partner/docs/v1/assetMatchPolicy/update
def update_params
super.tap do |params|
params[:path] = "/youtube/partner/v1/assets/#{@asset_id}/matchPolicy"
params[:params] = {on_behalf_of_content_owner: @auth.owner_name}
Expand All @@ -31,4 +29,4 @@ def patch_params
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/yt/version.rb
@@ -1,3 +1,3 @@
module Yt
VERSION = '0.32.4'
VERSION = '0.32.5'
end

0 comments on commit d70171d

Please sign in to comment.