prx_client 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Rakefile +1 -0
- data/lib/prx/client.rb +9 -9
- data/lib/prx/client/version.rb +1 -1
- data/lib/prx/model.rb +5 -0
- data/lib/prx/model/account.rb +1 -4
- data/lib/prx/model/audio_file.rb +2 -3
- data/lib/prx/model/audio_version.rb +1 -2
- data/lib/prx/model/base.rb +5 -2
- data/lib/prx/model/license.rb +1 -2
- data/lib/prx/model/network.rb +1 -2
- data/lib/prx/model/piece.rb +1 -2
- data/lib/prx/model/producer.rb +1 -2
- data/lib/prx/model/series.rb +1 -3
- data/lib/prx/model/user.rb +1 -2
- data/lib/prx/representer.rb +4 -0
- data/lib/prx/representer/full/account_representer.rb +4 -6
- data/lib/prx/representer/full/audio_file_representer.rb +5 -8
- data/lib/prx/representer/full/audio_version_representer.rb +6 -8
- data/lib/prx/representer/full/license_representer.rb +4 -6
- data/lib/prx/representer/full/network_representer.rb +4 -7
- data/lib/prx/representer/full/piece_representer.rb +13 -8
- data/lib/prx/representer/full/producer_representer.rb +4 -6
- data/lib/prx/representer/full/series_representer.rb +4 -7
- data/lib/prx/representer/full/user_representer.rb +4 -7
- data/lib/prx/representer/min/account_representer.rb +3 -6
- data/lib/prx/representer/min/network_representer.rb +6 -7
- data/lib/prx/representer/min/series_representer.rb +4 -5
- data/lib/prx/representer/min/user_representer.rb +6 -7
- data/lib/prx_client.rb +3 -6
- data/prx_client.gemspec +2 -2
- data/test/test_account.rb +1 -1
- data/test/test_audio_file.rb +2 -2
- data/test/test_audio_version.rb +2 -2
- data/test/test_client.rb +10 -10
- data/test/test_piece.rb +11 -10
- metadata +42 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff5c7d086730f1d1f0205f6f02f4d07859d7de55
|
4
|
+
data.tar.gz: 002ddf3087d6a0f8de922e2c5073a1e9a8f25b0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b3f66e75cbb51d5415151e16a898fcf883b015396f10f831e29da4d6421ec1b8ef0d7c1e7880e14be347b15bb6935bc55118ca829d2c1630aad30ed3f03b79e
|
7
|
+
data.tar.gz: 1ea893ff9cbdfb42204942f757b3159b28ed0e6303668f06970f1c02f8aff9e1673379eb96e40b8fac44d5a19e7ed2ca41143f73075dc244973f24b40037cda6
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/lib/prx/client.rb
CHANGED
@@ -9,9 +9,9 @@ module PRX
|
|
9
9
|
module Client
|
10
10
|
|
11
11
|
class << self
|
12
|
-
|
12
|
+
|
13
13
|
include PRX::Model
|
14
|
-
|
14
|
+
|
15
15
|
attr_accessor :key, :secret, :scheme, :host, :port, :version, :token
|
16
16
|
|
17
17
|
|
@@ -21,18 +21,18 @@ module PRX
|
|
21
21
|
action = opts.delete(:action) || :get
|
22
22
|
opts = default_options.merge(opts)
|
23
23
|
|
24
|
-
path = api_path(path) unless path
|
24
|
+
path = api_path(path) unless path[0] == '/'
|
25
25
|
response = access_token.send(action, path, opts)
|
26
26
|
# puts response.inspect
|
27
27
|
response
|
28
28
|
end
|
29
29
|
|
30
30
|
protected
|
31
|
-
|
31
|
+
|
32
32
|
def api_path(path)
|
33
33
|
"/api/#{version}/#{path}"
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def access_token
|
37
37
|
OAuth2::AccessToken.new(client, token, {})
|
38
38
|
end
|
@@ -52,15 +52,15 @@ module PRX
|
|
52
52
|
def site
|
53
53
|
"#{scheme || 'http'}://#{host}:#{port}"
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def default_options
|
57
57
|
{
|
58
58
|
'Accept' => 'application/json',
|
59
59
|
'Content-Type' => 'application/json'
|
60
60
|
}
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|
data/lib/prx/client/version.rb
CHANGED
data/lib/prx/model.rb
CHANGED
data/lib/prx/model/account.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/account_representer'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Model
|
7
6
|
class Account < PRX::Model::Base
|
8
|
-
|
9
|
-
include Roar::Representer::JSON
|
7
|
+
include Roar::JSON
|
10
8
|
include PRX::Representer::Full::AccountRepresenter
|
11
9
|
|
12
10
|
attr_accessor :name, :path, :type_name
|
13
|
-
|
14
11
|
end
|
15
12
|
end
|
16
13
|
end
|
data/lib/prx/model/audio_file.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/audio_file_representer'
|
4
3
|
|
@@ -6,12 +5,12 @@ module PRX
|
|
6
5
|
module Model
|
7
6
|
class AudioFile < PRX::Model::Base
|
8
7
|
|
9
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
10
9
|
include PRX::Representer::Full::AudioFileRepresenter
|
11
10
|
|
12
11
|
attr_accessor :label, :content_type, :size, :status, :length, :url
|
13
12
|
attr_reader :attach_file
|
14
|
-
|
13
|
+
|
15
14
|
def attach_file=(f)
|
16
15
|
@attach_file = f
|
17
16
|
prepare_file_upload if f
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/audio_version_representer'
|
4
3
|
|
@@ -6,7 +5,7 @@ module PRX
|
|
6
5
|
module Model
|
7
6
|
class AudioVersion < PRX::Model::Base
|
8
7
|
|
9
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
10
9
|
include PRX::Representer::Full::AudioVersionRepresenter
|
11
10
|
|
12
11
|
attr_accessor :label,:content_advisory,:timing_and_cues,:transcript,:news_hole_break,:floating_break,:bottom_of_hour_break,:twenty_forty_break,:audio_files
|
data/lib/prx/model/base.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
require 'roar/decorator'
|
2
|
+
require 'roar/json'
|
3
|
+
|
1
4
|
module PRX
|
2
5
|
module Model
|
3
6
|
class Base
|
4
|
-
|
7
|
+
include ActiveModel::Model
|
5
8
|
attr_accessor :id
|
6
9
|
|
7
10
|
def initialize(*args)
|
@@ -19,7 +22,7 @@ module PRX
|
|
19
22
|
opts = {
|
20
23
|
:action => (id ? :put : :post),
|
21
24
|
:path => (id ? "#{class_path_part}/#{id}" : class_path_part),
|
22
|
-
:body =>
|
25
|
+
:body => to_hash
|
23
26
|
}
|
24
27
|
response = request(opts)
|
25
28
|
self.from_json(response.response.body)
|
data/lib/prx/model/license.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/license_representer'
|
4
3
|
|
@@ -6,7 +5,7 @@ module PRX
|
|
6
5
|
module Model
|
7
6
|
class License < PRX::Model::Base
|
8
7
|
|
9
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
10
9
|
include PRX::Representer::Full::LicenseRepresenter
|
11
10
|
|
12
11
|
attr_accessor :website_usage, :allow_edit, :additional_terms
|
data/lib/prx/model/network.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/network_representer'
|
4
3
|
|
@@ -6,7 +5,7 @@ module PRX
|
|
6
5
|
module Model
|
7
6
|
class Network < PRX::Model::Base
|
8
7
|
|
9
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
10
9
|
include PRX::Representer::Full::NetworkRepresenter
|
11
10
|
|
12
11
|
attr_accessor :name, :path
|
data/lib/prx/model/piece.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/piece_representer'
|
4
3
|
|
@@ -6,7 +5,7 @@ module PRX
|
|
6
5
|
module Model
|
7
6
|
class Piece < PRX::Model::Base
|
8
7
|
|
9
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
10
9
|
include PRX::Representer::Full::PieceRepresenter
|
11
10
|
|
12
11
|
attr_accessor :title, :short_description, :description, :account_id, :published_at, :created_at, :produced_on
|
data/lib/prx/model/producer.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/producer_representer'
|
4
3
|
|
@@ -6,7 +5,7 @@ module PRX
|
|
6
5
|
module Model
|
7
6
|
class Producer < PRX::Model::Base
|
8
7
|
|
9
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
10
9
|
include PRX::Representer::Full::ProducerRepresenter
|
11
10
|
|
12
11
|
attr_accessor :name, :email, :user
|
data/lib/prx/model/series.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'prx/model/base'
|
2
2
|
require 'prx/representer/full/series_representer'
|
3
3
|
|
4
|
-
require 'roar/representer/json'
|
5
|
-
|
6
4
|
module PRX
|
7
5
|
module Model
|
8
6
|
class Series < PRX::Model::Base
|
9
7
|
|
10
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
11
9
|
include PRX::Representer::Full::SeriesRepresenter
|
12
10
|
|
13
11
|
attr_accessor :title, :subscribable
|
data/lib/prx/model/user.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/representer/json'
|
2
1
|
require 'prx/model/base'
|
3
2
|
require 'prx/representer/full/user_representer'
|
4
3
|
|
@@ -6,7 +5,7 @@ module PRX
|
|
6
5
|
module Model
|
7
6
|
class User < PRX::Model::Base
|
8
7
|
|
9
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
10
9
|
include PRX::Representer::Full::UserRepresenter
|
11
10
|
|
12
11
|
attr_accessor :login, :email, :first_name, :last_name
|
data/lib/prx/representer.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
3
3
|
|
4
4
|
module PRX
|
5
5
|
module Representer
|
6
6
|
module Full
|
7
7
|
module AccountRepresenter
|
8
|
-
|
9
|
-
include Roar::
|
10
|
-
include Roar::Representer::JSON
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
11
10
|
|
12
11
|
property :id
|
13
12
|
property :name
|
14
13
|
property :path
|
15
14
|
property :type_name, :from=>:type
|
16
|
-
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Full
|
8
7
|
module AudioFileRepresenter
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
9
10
|
|
10
|
-
include Roar::Representer::Feature::Hypermedia
|
11
|
-
include Roar::Representer::JSON
|
12
|
-
|
13
11
|
property :id
|
14
12
|
property :label
|
15
13
|
property :attach_file
|
@@ -17,8 +15,7 @@ module PRX
|
|
17
15
|
property :size
|
18
16
|
property :status
|
19
17
|
property :length
|
20
|
-
property :url, :if => lambda {|opts| opts[:link_audio]}
|
21
|
-
|
18
|
+
property :url, :if => lambda {|opts| opts[:link_audio]}
|
22
19
|
end
|
23
20
|
end
|
24
21
|
end
|
@@ -1,15 +1,14 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require '
|
4
|
-
require
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
3
|
+
require 'prx/model/audio_file'
|
4
|
+
require 'prx/representer/full/audio_file_representer'
|
5
5
|
|
6
6
|
module PRX
|
7
7
|
module Representer
|
8
8
|
module Full
|
9
9
|
module AudioVersionRepresenter
|
10
|
-
|
11
|
-
include Roar::
|
12
|
-
include Roar::Representer::JSON
|
10
|
+
include Roar::JSON
|
11
|
+
include Roar::Hypermedia
|
13
12
|
|
14
13
|
property :id
|
15
14
|
property :label
|
@@ -24,7 +23,6 @@ module PRX
|
|
24
23
|
collection :audio_files,
|
25
24
|
:class => PRX::Model::AudioFile,
|
26
25
|
:extend => PRX::Representer::Full::AudioFileRepresenter
|
27
|
-
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Full
|
8
7
|
module LicenseRepresenter
|
9
|
-
|
10
|
-
include Roar::
|
11
|
-
include Roar::Representer::JSON
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
12
10
|
|
13
11
|
property :id
|
14
12
|
property :website_usage
|
@@ -1,19 +1,16 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Full
|
8
7
|
module NetworkRepresenter
|
9
|
-
|
10
|
-
include Roar::
|
11
|
-
include Roar::Representer::JSON
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
12
10
|
|
13
11
|
property :id
|
14
12
|
property :name
|
15
13
|
property :path
|
16
|
-
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
@@ -1,6 +1,13 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
3
|
+
|
4
|
+
require "prx/model/audio_version"
|
5
|
+
require "prx/model/license"
|
6
|
+
require "prx/model/producer"
|
7
|
+
require "prx/model/user"
|
8
|
+
require "prx/model/account"
|
9
|
+
require "prx/model/series"
|
10
|
+
require "prx/model/network"
|
4
11
|
|
5
12
|
require "prx/representer/min/account_representer"
|
6
13
|
require "prx/representer/min/network_representer"
|
@@ -15,9 +22,8 @@ module PRX
|
|
15
22
|
module Representer
|
16
23
|
module Full
|
17
24
|
module PieceRepresenter
|
18
|
-
|
19
|
-
include Roar::
|
20
|
-
include Roar::Representer::JSON
|
25
|
+
include Roar::JSON
|
26
|
+
include Roar::Hypermedia
|
21
27
|
|
22
28
|
property :id
|
23
29
|
property :title
|
@@ -43,7 +49,7 @@ module PRX
|
|
43
49
|
property :point_level
|
44
50
|
property :network_only
|
45
51
|
property :publish_on_valid
|
46
|
-
|
52
|
+
|
47
53
|
# child models we provide full
|
48
54
|
property :promos,
|
49
55
|
:class => PRX::Model::AudioVersion,
|
@@ -77,7 +83,6 @@ module PRX
|
|
77
83
|
collection :networks,
|
78
84
|
:class => PRX::Model::Network,
|
79
85
|
:extend => PRX::Representer::Min::NetworkRepresenter
|
80
|
-
|
81
86
|
end
|
82
87
|
end
|
83
88
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
require "prx/representer/min/user_representer"
|
6
5
|
|
@@ -8,9 +7,8 @@ module PRX
|
|
8
7
|
module Representer
|
9
8
|
module Full
|
10
9
|
module ProducerRepresenter
|
11
|
-
|
12
|
-
include Roar::
|
13
|
-
include Roar::Representer::JSON
|
10
|
+
include Roar::JSON
|
11
|
+
include Roar::Hypermedia
|
14
12
|
|
15
13
|
property :id
|
16
14
|
property :name
|
@@ -1,18 +1,15 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Full
|
8
7
|
module SeriesRepresenter
|
9
|
-
|
10
|
-
include Roar::
|
11
|
-
include Roar::Representer::JSON
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
12
10
|
|
13
11
|
property :id
|
14
12
|
property :title
|
15
|
-
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -1,21 +1,18 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Full
|
8
7
|
module UserRepresenter
|
9
|
-
|
10
|
-
include Roar::
|
11
|
-
include Roar::Representer::JSON
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
12
10
|
|
13
11
|
property :id
|
14
12
|
property :login
|
15
13
|
property :email
|
16
14
|
property :first_name
|
17
15
|
property :last_name
|
18
|
-
|
19
16
|
end
|
20
17
|
end
|
21
18
|
end
|
@@ -1,19 +1,16 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/representer/json'
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
4
2
|
|
5
3
|
module PRX
|
6
4
|
module Representer
|
7
5
|
module Min
|
8
6
|
module AccountRepresenter
|
9
|
-
include Roar::
|
10
|
-
# include Roar::
|
7
|
+
include Roar::JSON
|
8
|
+
# include Roar::Hypermedia
|
11
9
|
|
12
10
|
property :id
|
13
11
|
property :name
|
14
12
|
property :path
|
15
13
|
property :type_name, :from=>:type
|
16
|
-
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
@@ -1,18 +1,17 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Min
|
8
7
|
module NetworkRepresenter
|
9
|
-
include Roar::
|
10
|
-
include Roar::
|
11
|
-
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
10
|
+
|
12
11
|
property :id
|
13
12
|
property :name
|
14
13
|
property :path
|
15
|
-
|
14
|
+
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -1,13 +1,12 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Min
|
8
7
|
module SeriesRepresenter
|
9
|
-
include Roar::
|
10
|
-
include Roar::
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
11
10
|
|
12
11
|
property :id
|
13
12
|
property :title
|
@@ -1,20 +1,19 @@
|
|
1
|
-
require 'roar/
|
2
|
-
require 'roar/
|
3
|
-
require 'roar/representer/feature/hypermedia'
|
1
|
+
require 'roar/json'
|
2
|
+
require 'roar/hypermedia'
|
4
3
|
|
5
4
|
module PRX
|
6
5
|
module Representer
|
7
6
|
module Min
|
8
7
|
module UserRepresenter
|
9
|
-
include Roar::
|
10
|
-
include Roar::
|
11
|
-
|
8
|
+
include Roar::JSON
|
9
|
+
include Roar::Hypermedia
|
10
|
+
|
12
11
|
property :id
|
13
12
|
property :login
|
14
13
|
property :email
|
15
14
|
property :first_name
|
16
15
|
property :last_name
|
17
|
-
|
16
|
+
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
data/lib/prx_client.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
require 'i18n'
|
2
2
|
require 'oauth2'
|
3
3
|
require 'json'
|
4
|
-
|
5
4
|
require 'active_support'
|
6
|
-
require '
|
7
|
-
require 'active_support/core_ext/module'
|
8
|
-
require 'active_support/core_ext/module/aliasing'
|
9
|
-
require 'active_support/json/encoding'
|
10
|
-
require 'active_support/all'
|
5
|
+
require 'active_model'
|
11
6
|
|
12
7
|
require 'prx/client/version'
|
8
|
+
require 'prx/model'
|
9
|
+
require 'prx/representer'
|
data/prx_client.gemspec
CHANGED
@@ -18,15 +18,15 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
s.add_runtime_dependency "json"
|
20
20
|
s.add_runtime_dependency "activesupport"
|
21
|
+
s.add_runtime_dependency "activemodel"
|
21
22
|
s.add_runtime_dependency "excon"
|
22
23
|
s.add_runtime_dependency "oauth2"
|
23
24
|
s.add_runtime_dependency 'faraday'
|
24
|
-
s.add_runtime_dependency "roar"
|
25
|
+
s.add_runtime_dependency "roar", '>= 1.0.0'
|
25
26
|
|
26
27
|
# specify any dependencies here; for example:
|
27
28
|
s.add_development_dependency "rake"
|
28
29
|
s.add_development_dependency "test-unit"
|
29
30
|
s.add_development_dependency 'webmock'
|
30
31
|
s.add_development_dependency "dotenv"
|
31
|
-
|
32
32
|
end
|
data/test/test_account.rb
CHANGED
data/test/test_audio_file.rb
CHANGED
@@ -8,7 +8,7 @@ class PRX::TestAudioFile < Test::Unit::TestCase
|
|
8
8
|
def test_initialize
|
9
9
|
af = PRX::Model::AudioFile.new(:id=>1, :label=>'l', :size=>3000, :length=>30, :status=>'new', :content_type=>'audio/wav' )
|
10
10
|
assert af.is_a?(PRX::Model::AudioFile)
|
11
|
-
assert af.
|
11
|
+
assert af.to_hash === {"label"=>"l", "size"=>3000, "content_type"=>"audio/wav", "id"=>1, "length"=>30, "status"=>"new"}
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_default_content_type
|
@@ -20,5 +20,5 @@ class PRX::TestAudioFile < Test::Unit::TestCase
|
|
20
20
|
af = PRX::Model::AudioFile.new(:attach_file=>"#{File.dirname(__FILE__)}/files/test.mp2")
|
21
21
|
assert af.attach_file.is_a?(Faraday::UploadIO)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
data/test/test_audio_version.rb
CHANGED
@@ -19,9 +19,9 @@ class PRX::TestAudioVersion < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
def test_initialize_with_json
|
21
21
|
json = {"label"=>"l", "audio_files"=>[{"label"=>"af"}]}.to_json
|
22
|
-
af = PRX::Model::AudioVersion.from_json(json)
|
22
|
+
af = PRX::Model::AudioVersion.new.from_json(json)
|
23
23
|
assert af.is_a?(PRX::Model::AudioVersion)
|
24
24
|
assert af.audio_files.first.is_a?(PRX::Model::AudioFile)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
end
|
data/test/test_client.rb
CHANGED
@@ -4,14 +4,14 @@ require 'prx/client'
|
|
4
4
|
require 'prx/model'
|
5
5
|
|
6
6
|
class PRX::TestClient < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
PRX::Client.key = '
|
10
|
-
PRX::Client.secret = '
|
7
|
+
|
8
|
+
def setup
|
9
|
+
PRX::Client.key = 'keykeykeykeykeykeykeykeykeykeykeykeykeyk'
|
10
|
+
PRX::Client.secret = 'secretsecretsecretsecretsecretsecretsecr'
|
11
11
|
PRX::Client.host = "development.prx.org"
|
12
12
|
PRX::Client.port = 3001
|
13
13
|
PRX::Client.version = 'v2'
|
14
|
-
PRX::Client.token = '
|
14
|
+
PRX::Client.token = 'tokentokentokentokentokentokentokentoken'
|
15
15
|
|
16
16
|
@user_info = {
|
17
17
|
:uid => '1001',
|
@@ -28,7 +28,7 @@ class PRX::TestClient < Test::Unit::TestCase
|
|
28
28
|
|
29
29
|
def test_me
|
30
30
|
stub_request(:get, "http://development.prx.org:3001/me").
|
31
|
-
with(:headers => {'Authorization'=>'Bearer
|
31
|
+
with(:headers => {'Authorization'=>'Bearer tokentokentokentokentokentokentokentoken', 'Host'=>'development.prx.org:3001'}).
|
32
32
|
to_return(:status => 200, :body => @user_info.to_json, :headers => {})
|
33
33
|
|
34
34
|
response = PRX::Model::User.me
|
@@ -41,7 +41,7 @@ class PRX::TestClient < Test::Unit::TestCase
|
|
41
41
|
:description=>'test description',
|
42
42
|
:account=>PRX::Model::Account.new(:id=>8),
|
43
43
|
:producers=>[PRX::Model::Producer.new(:name=>'Producer')])
|
44
|
-
|
44
|
+
|
45
45
|
p.add_audio(:label=>'test', :attach_file=>"#{File.dirname(__FILE__)}/files/test.mp2", :content_type=>'audio/mpeg')
|
46
46
|
# puts p.inspect
|
47
47
|
|
@@ -52,7 +52,7 @@ class PRX::TestClient < Test::Unit::TestCase
|
|
52
52
|
:headers => {"Content-Length"=>"1118", "Set-Cookie"=>"_prx_session_development=BAh7BzoPc2Vzc2lvbl9pZCIlZDk1NGFmZWQzNDhkZDI4ZDBmMmEzN2YwMzhmZjRiODc6DHVzZXJfaWRpDQ%3D%3D--c307c1d85dacd9d35aead604008e10064684065f; path=/; HttpOnly", "ETag"=>"\"7444da1c82c7cac604f9bc2b94cd6e7b\"", "Cache-Control"=>"private, max-age=0, must-revalidate", "Content-Type"=>"application/json; charset=utf-8", "X-Runtime"=>"985", "Connection"=>"keep-alive"}
|
53
53
|
)
|
54
54
|
|
55
|
-
response = PRX::Client.request({:action => :post, :path => 'pieces', :body => p.
|
55
|
+
response = PRX::Client.request({:action => :post, :path => 'pieces', :body => p.to_hash})
|
56
56
|
|
57
57
|
assert response
|
58
58
|
|
@@ -69,10 +69,10 @@ class PRX::TestClient < Test::Unit::TestCase
|
|
69
69
|
to_return(
|
70
70
|
:status => 200,
|
71
71
|
:body => "{\"short_description\":\"Episode 12345 of the new Public Radio Remix Select series. Based on Remix 24 episode 54321.\",\"length\":0,\"series\":{\"title\":\"Public Radio Remix Select\",\"id\":32346},\"creator\":{\"first_name\":\"PRX\",\"last_name\":\"Administrator\",\"login\":\"admin\",\"email\":\"admin@prx.org\",\"id\":8},\"publish_on_valid\":true,\"description\":\"this is the description, and it is very long\",\"license\":{\"allow_edit\":\"only with permission\",\"id\":169778,\"website_usage\":\"as a free MP3 download and stream\"},\"promos\":{\"label\":\"Promos\",\"id\":200467,\"audio_files\":[]},\"point_level\":0,\"account_id\":98822,\"title\":\"Remix Select: Episode 12345\",\"id\":88474,\"is_shareable\":true,\"allow_comments\":true,\"episode_number\":12345,\"networks\":[{\"id\":23,\"path\":\"remix-select\",\"name\":\"Public Radio Remix Select\"}],\"account\":{\"id\":98822,\"type\":\"Group\",\"path\":\"remix\",\"name\":\"Public Radio Remix\"},\"network_only\":true,\"producers\":[{\"user\":{\"first_name\":\"PRX\",\"last_name\":\"Administrator\",\"login\":\"admin\",\"email\":\"admin@prx.org\",\"id\":8},\"id\":100458}],\"audio_versions\":[{\"label\":\"Piece Audio\",\"id\":200467,\"audio_files\":[]}],\"created_at\":\"2014-03-18T10:20:11-04:00\"}",
|
72
|
-
:headers => {"Content-Length"=>"1118", "
|
72
|
+
:headers => {"Content-Length"=>"1118", "Cache-Control"=>"private, max-age=0, must-revalidate", "Content-Type"=>"application/json; charset=utf-8", "X-Runtime"=>"985", "Connection"=>"keep-alive"}
|
73
73
|
)
|
74
74
|
|
75
|
-
response = PRX::Client.request({:action => :post, :path => 'pieces', :body => p.
|
75
|
+
response = PRX::Client.request({:action => :post, :path => 'pieces', :body => p.to_hash})
|
76
76
|
|
77
77
|
assert response
|
78
78
|
|
data/test/test_piece.rb
CHANGED
@@ -13,13 +13,15 @@ class PRX::TestPiece < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_initialize_with_account_json
|
16
|
-
a = PRX::Model::Piece.from_json({:title=>'t', :id=>1, :account=>{:id=>2}}.to_json)
|
16
|
+
a = PRX::Model::Piece.new.from_json({:title=>'t', :id=>1, :account=>{:id=>2}}.to_json)
|
17
17
|
assert a.account.is_a?(PRX::Model::Account)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_initialize_with_account_object
|
21
|
-
|
21
|
+
json = {:title=>'t', :id=>1, :account=>{id: 2}}.to_json
|
22
|
+
a = PRX::Model::Piece.new.from_json(json)
|
22
23
|
assert a.account.is_a?(PRX::Model::Account)
|
24
|
+
assert a.account.id == 2
|
23
25
|
end
|
24
26
|
|
25
27
|
def test_piece_with_local_file
|
@@ -64,19 +66,18 @@ class PRX::TestPiece < Test::Unit::TestCase
|
|
64
66
|
:point_level => 0,
|
65
67
|
:publish_on_valid => true
|
66
68
|
)
|
67
|
-
|
69
|
+
piece.add_audio(:label=>'audio', :attach_file=>"s3://remix/path/file.mp3", :size=>1)
|
68
70
|
# puts "\n\npiece before saved: #{piece.to_json}"
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
stub_request(:post, "http://development.prx.org:3001/api/v2/pieces").
|
73
|
+
to_return(
|
74
|
+
:status => 200,
|
75
|
+
:body => "{\"short_description\":\"Episode 12345 of the new Public Radio Remix Select series. Based on Remix 24 episode 54321.\",\"length\":0,\"series\":{\"title\":\"Public Radio Remix Select\",\"id\":32346},\"creator\":{\"first_name\":\"PRX\",\"last_name\":\"Administrator\",\"login\":\"admin\",\"email\":\"admin@prx.org\",\"id\":8},\"publish_on_valid\":true,\"description\":\"this is the description, and it is very long\",\"license\":{\"allow_edit\":\"only with permission\",\"id\":169778,\"website_usage\":\"as a free MP3 download and stream\"},\"promos\":{\"label\":\"Promos\",\"id\":200467,\"audio_files\":[]},\"point_level\":0,\"account_id\":98822,\"title\":\"Remix Select: Episode 12345\",\"id\":88474,\"is_shareable\":true,\"allow_comments\":true,\"episode_number\":12345,\"networks\":[{\"id\":23,\"path\":\"remix-select\",\"name\":\"Public Radio Remix Select\"}],\"account\":{\"id\":98822,\"type\":\"Group\",\"path\":\"remix\",\"name\":\"Public Radio Remix\"},\"network_only\":true,\"producers\":[{\"user\":{\"first_name\":\"PRX\",\"last_name\":\"Administrator\",\"login\":\"admin\",\"email\":\"admin@prx.org\",\"id\":8},\"id\":100458}],\"audio_versions\":[{\"label\":\"Piece Audio\",\"id\":200467,\"audio_files\":[]}],\"created_at\":\"2014-03-18T10:20:11-04:00\"}",
|
76
|
+
:headers => {"Content-Length"=>"1118", "Cache-Control"=>"private, max-age=0, must-revalidate", "Content-Type"=>"application/json; charset=utf-8", "X-Runtime"=>"985", "Connection"=>"keep-alive"}
|
77
|
+
)
|
76
78
|
|
77
79
|
piece.save
|
78
80
|
assert piece.id && (piece.id > 0)
|
79
81
|
# puts "\n\npiece after saved: #{piece.to_json}"
|
80
82
|
end
|
81
|
-
|
82
83
|
end
|
metadata
CHANGED
@@ -1,153 +1,167 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prx_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kuklewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activemodel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: excon
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: oauth2
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: faraday
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :runtime
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: roar
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 1.0.0
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 1.0.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - ">="
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: test-unit
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: webmock
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- -
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- -
|
150
|
+
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: dotenv
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- -
|
157
|
+
- - ">="
|
144
158
|
- !ruby/object:Gem::Version
|
145
159
|
version: '0'
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- -
|
164
|
+
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
167
|
description: Client for PRX OAuth2 API (v2)
|
@@ -157,7 +171,7 @@ executables: []
|
|
157
171
|
extensions: []
|
158
172
|
extra_rdoc_files: []
|
159
173
|
files:
|
160
|
-
- .gitignore
|
174
|
+
- ".gitignore"
|
161
175
|
- Gemfile
|
162
176
|
- Rakefile
|
163
177
|
- lib/prx/client.rb
|
@@ -210,17 +224,17 @@ require_paths:
|
|
210
224
|
- lib
|
211
225
|
required_ruby_version: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
|
-
- -
|
227
|
+
- - ">="
|
214
228
|
- !ruby/object:Gem::Version
|
215
229
|
version: '0'
|
216
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
231
|
requirements:
|
218
|
-
- -
|
232
|
+
- - ">="
|
219
233
|
- !ruby/object:Gem::Version
|
220
234
|
version: '0'
|
221
235
|
requirements: []
|
222
236
|
rubyforge_project:
|
223
|
-
rubygems_version: 2.
|
237
|
+
rubygems_version: 2.6.14.4
|
224
238
|
signing_key:
|
225
239
|
specification_version: 4
|
226
240
|
summary: Client for PRX OAuth2 API (v2)
|