zype 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56694d40bfb11001c7dccf20c36faa1484fbf6192de53c155aa2c1a2ba5cc70e
4
- data.tar.gz: 39f24a687917314941f767318d7f2c471a2d8ac88c96b65a644ed4d7079c7195
3
+ metadata.gz: 57fe0dfb7717b479c07e248e6f8f8d207fd6bf912d268b7fb962326ab6a09d20
4
+ data.tar.gz: 3ce711104f8a2ca52919b1f25e4f229b831c0b69e0e7b8f2e832380932631509
5
5
  SHA512:
6
- metadata.gz: e83da8832a96bf75e87645e5d8412db0abb030787c6d09392ff9bb6abc7fc623d002285834ce2acd0070561f81c5b996c8d1c965f5b07c1ba27790cd72afa64b
7
- data.tar.gz: e0dbcaa55df7a4ad9b855e18b7f5e9005a501d97c5a8b95a6e002160e15815bfbd884ae0e1764b5c84d4f0eaa3402acb9da6ba559d2f0e4db47338f136d21037
6
+ metadata.gz: 76401b9bc09baba4c972939a115dd74aeca7749681b8fefb9c6ee5fb619207777aff832b5bcedb937fe3b6a31fff5b87e22c2a7e331f440385238ecbca083a4a
7
+ data.tar.gz: 3ae653edf12bec378b0d3532ffd3ab4444e1152d4a1c38e72505bd5602badb8ccb490dafb65aa94039d3b6d3836d882ff506a38fb42426ccb44098d53e511a19
data/lib/zype.rb CHANGED
@@ -4,6 +4,7 @@ require 'zype/models.rb'
4
4
  require 'zype/client.rb'
5
5
  require 'zype/client/player_client.rb'
6
6
  require 'zype/client/api_client.rb'
7
+ require 'zype/client/login_client.rb'
7
8
  require 'zype/base_model.rb'
8
9
 
9
10
  Dir[File.join(__dir__, '../lib/zype/models/base', '*.rb')].each { |file| require file }
@@ -0,0 +1,17 @@
1
+ module Zype
2
+ class LoginClient < Zype::Client
3
+ def initialize(_ = '')
4
+ @headers = { 'Content-Type' => 'application/json' }
5
+ self.class.base_uri Zype.configuration.login_host
6
+ end
7
+
8
+ def execute(method:, path:, params: {})
9
+ resp = send(method, path: path, params: params)
10
+ if resp.success?
11
+ resp['response'].nil? ? resp.parsed_response : resp['response']
12
+ else
13
+ error!(code: resp.code, message: resp['message'])
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,12 +1,13 @@
1
1
  module Zype
2
2
  class Configuration
3
- attr_accessor :api_key, :host, :player_host, :app_key
3
+ attr_accessor :api_key, :host, :player_host, :login_host, :app_key
4
4
 
5
5
  def initialize
6
6
  @api_key = nil
7
7
  @app_key = nil
8
8
  @host = 'https://api.zype.com'
9
9
  @player_host = 'https://player.zype.com'
10
+ @login_host = 'https://login.zype.com'
10
11
  end
11
12
  end
12
13
  end
data/lib/zype/models.rb CHANGED
@@ -2,7 +2,7 @@ module Zype
2
2
  class Models
3
3
  # Have to list out available methods instead of using Dir
4
4
  LIST = %w[ad_tags apps categories category_content_rules consumers device_categories devices encoders geo_ip live_events
5
- live_manifests manifests pin plans players playlist_content_rules playlist_entitlements playlists
5
+ live_manifests manifests oauth pin plans players playlist_content_rules playlist_entitlements playlists
6
6
  program_guides redemption_codes revenue_models segments subscriptions subtitle_playlists subtitles
7
7
  transactions users video_content_rules video_entitlements videos video_favorites video_imports video_sources
8
8
  zobject_types zobjects
@@ -0,0 +1,31 @@
1
+ module Zype
2
+ # Read more at https://docs.zype.com/v1.0/reference#oauth-1
3
+ # This class only supports create and status methods
4
+ #
5
+ # To use this class, you must set `login_host`
6
+ # @since 0.19.0
7
+ class Oauth < Zype::BaseModel
8
+ %i[all find update delete].each do |mtd|
9
+ send(:define_method, mtd) do
10
+ raise NoMethodError
11
+ end
12
+ end
13
+ # Check the status of the current access token
14
+ #
15
+ # @param access_token [String] current access token
16
+ # @return [Hash] information about the token. When it expires, etc.
17
+ def status(access_token:)
18
+ client.execute(method: :get, path: "/#{path}/info", params: { access_token: access_token })
19
+ end
20
+
21
+ private
22
+
23
+ def path
24
+ @path = 'oauth/token'
25
+ end
26
+
27
+ def client_class
28
+ Zype::LoginClient
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zype
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-13 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -62,6 +62,7 @@ files:
62
62
  - lib/zype/base_model.rb
63
63
  - lib/zype/client.rb
64
64
  - lib/zype/client/api_client.rb
65
+ - lib/zype/client/login_client.rb
65
66
  - lib/zype/client/player_client.rb
66
67
  - lib/zype/configuration.rb
67
68
  - lib/zype/models.rb
@@ -81,6 +82,7 @@ files:
81
82
  - lib/zype/models/live_events.rb
82
83
  - lib/zype/models/live_manifests.rb
83
84
  - lib/zype/models/manifests.rb
85
+ - lib/zype/models/oauth.rb
84
86
  - lib/zype/models/pin.rb
85
87
  - lib/zype/models/plans.rb
86
88
  - lib/zype/models/players.rb