onescreen-api-client 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.txt ADDED
File without changes
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 OneScreen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = onescreen-api-client
2
+
3
+ Is tool to be used against the OneScreen API. It allows clients to build their own interface to front the OneScreen Service.
4
+
5
+ == Contributing to onescreen-api-client
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 OneScreen Inc. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,14 @@
1
+ require 'active_resource'
2
+ $:.unshift(File.dirname(__FILE__))
3
+ require 'resources/base'
4
+ require 'resources/account'
5
+ require 'resources/asset'
6
+ require 'resources/error'
7
+ require 'resources/login'
8
+ require 'resources/media_source'
9
+ require 'resources/networks_affiliate'
10
+ require 'resources/player'
11
+ require 'resources/playlist'
12
+ require 'resources/signup'
13
+ require 'resources/site'
14
+ require 'resources/user'
@@ -0,0 +1,28 @@
1
+ module OneScreen
2
+ class Account < OneScreenBase
3
+
4
+ schema do
5
+ # Readable + Writable Properties
6
+ string 'organization', 'primary_website', 'address1', 'address2', 'city',
7
+ 'state', 'postal_code', 'country', 'phone', 'fax', 'tax_identifier'
8
+
9
+ # Readable Only Properties
10
+ # TODO: Unsupported type conversions Should be left as string
11
+ integer 'created_by', 'modified_by'
12
+ string 'row_version', 'created_at', 'modified_at'
13
+ end
14
+
15
+ validates :organization, :presence => true, :length => {:minimum=>3,:maximum=>100}
16
+ validates :primary_website, :length => {:minimum=>5,:maximum=>100}
17
+ validates :address1, :length => {:maximum=>100}
18
+ validates :address2, :length => {:maximum=>100}
19
+ validates :city, :length => {:maximum=>100}
20
+ validates :state, :length => {:minimum=>2,:maximum=>75}
21
+ validates :postal_code, :length => {:minimum=>5,:maximum=>15}
22
+ validates :country, :length => {:minimum=>2,:maximum=>75}
23
+ validates :phone, :length => {:minimum=>9,:maximum=>100}
24
+ validates :fax, :length => {:minimum=>9,:maximum=>15}
25
+ validates :tax_identifier, :length => {:minimum=>5,:maximum=>100}
26
+
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ module OneScreen
2
+ class Asset < OneScreenBase
3
+ read_only :uri
4
+
5
+ schema do
6
+ # Readable + Writable Properties
7
+ string 'name', 'tags'
8
+
9
+ # Readable Only Properties
10
+ # TODO: Unsupported type conversions Should be left as string
11
+ integer 'account_id', 'parent_id', 'created_by', 'modified_by'
12
+ string 'row_version', 'created_at', 'modified_at'
13
+ end
14
+
15
+ validates :name, :presence => true, :length => {:minimum=>5,:maximum=>100}
16
+ validates :account_id, :numericality => true
17
+ validates :tags, :length => {:maximum=>500}
18
+
19
+ end
20
+ end
@@ -0,0 +1,44 @@
1
+ module OneScreen
2
+ class OneScreenBase < ActiveResource::Base
3
+
4
+ self.timeout = 20
5
+ self.site = "http://api.onescreen.net/"
6
+ # self.format = ActiveResource::Formats::JsonFormat
7
+
8
+ class << self
9
+ attr_reader :read_only_attributes
10
+
11
+ def read_only(*values)
12
+ @read_only_attributes ||= []
13
+ @read_only_attributes.concat(values)
14
+ @read_only_attributes.uniq!
15
+ end
16
+
17
+ # If headers are not defined in a given subclass, then obtain
18
+ # headers from the superclass.
19
+ def headers
20
+ if defined?(@headers)
21
+ @headers
22
+ elsif superclass != Object && superclass.headers
23
+ superclass.headers
24
+ else
25
+ @headers ||= {}
26
+ end
27
+ end
28
+ end
29
+
30
+ def remove_read_only
31
+ self.class.read_only_attributes.each do |attr|
32
+ attributes.delete(attr)
33
+ end
34
+ end
35
+
36
+ def self.set_authentication_cookie(value)
37
+ self.headers.merge!("Cookie" => value)
38
+ end
39
+ def set_authentication_cookie(value)
40
+ self.class.headers.merge!("Cookie" => value)
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module OneScreen
2
+ class Error < OneScreenBase
3
+
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ module OneScreen
2
+ class Login < OneScreenBase
3
+
4
+ set_collection_name 'login'
5
+
6
+ schema do
7
+ string 'username', 'password', 'authentication_key'
8
+ integer 'user_id', 'account_id'
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ module OneScreen
2
+ class MediaSource < OneScreenBase
3
+
4
+ schema do
5
+ # Readable + Writable Properties
6
+ string 'name', 'short_description', 'long_description', 'tags'
7
+ integer 'parent_id', 'media_source_type_id'
8
+
9
+ # Readable Only Properties
10
+ # TODO: Unsupported type conversions Should be left as string
11
+ integer 'account_id', 'created_by', 'modified_by'
12
+ string 'row_version', 'created_at', 'modified_at', 'last_published_date'
13
+ end
14
+
15
+ validates :name, :presence => true, :length => {:minimum=>5,:maximum=>100}
16
+ validates :short_description, :length => {:maximum=>300}
17
+ validates :long_description, :length => {:maximum=>2000}
18
+ validates :tags, :length => {:maximum=>500}
19
+ validates :media_source_type_id, :presence => true, :numericality => true
20
+
21
+ public
22
+ def thumbnail_image
23
+ self.respond_to?(:thumbnail) ? self.thumbnail.uri : "http://mp.onescreen.net/u/a_mc/1000500/i/1000500_DA_OTk0NDUwMA==.jpg"
24
+ end
25
+ def preview_url
26
+ self.respond_to?(:preview) ? self.preview.uri : nil #"http://r.onescreen.net/f/OTk0NDQ4MA==";
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module OneScreen
2
+ class NetworksAffiliate < OneScreenBase
3
+
4
+ schema do
5
+ # Readable + Writable Properties
6
+ integer 'network_account_id', 'affiliate_account_id'
7
+ string 'is_approved'
8
+
9
+ # Readable Only Properties
10
+ # TODO: Unsupported type conversions Should be left as string
11
+ string 'network_account_name', 'affiliate_account_name'
12
+ string 'row_version', 'approved_at', 'is_approved'
13
+ end
14
+
15
+ validates :network_account_id, :presence => true, :numericality => true
16
+ validates :affiliate_account_id, :presence => true, :numericality => true
17
+ validates :is_approved, :inclusion => [true,false]
18
+
19
+ end
20
+ end
@@ -0,0 +1,103 @@
1
+ module OneScreen
2
+ class Player < OneScreenBase
3
+
4
+ attr_reader :settings_hash
5
+
6
+ schema do
7
+ # Readable + Writable Properties
8
+ string 'name', 'description', 'url', 'settings'
9
+
10
+ # Readable Only Properties
11
+ # TODO: Unsupported type conversions Should be left as string
12
+ integer 'account_id', 'created_by', 'modified_by'
13
+ string 'row_version', 'created_at', 'modified_at'
14
+ end
15
+
16
+ validates :name, :presence => true, :length => {:minimum=>5,:maximum=>100}
17
+ validates :url, :presence => true, :length => {:maximum=>250}
18
+ validates :settings, :presence => true, :length => {:maximum=>200}
19
+ validates :description, :length => {:maximum=>2000}
20
+
21
+ public
22
+ def skin_mapping
23
+ {
24
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/white.xml" => "FFFFFF",
25
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/embeddableSkin.xml" => "666666",
26
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/blueSkin.xml" => "4E6395",
27
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/realblueSkin.xml" => "097BBD",
28
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/lightblueSkin.xml" => "8290D1",
29
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/pinkSkin.xml" => "9F639E",
30
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/redSkin.xml" => "8F201A",
31
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/skin_hollyscoop.xml" => "CD3300",
32
+ "http://cdn.onescreen.net/os/mp/osmp/iframeAds/skins/greenSkin.xml" => "6B8429"
33
+ }
34
+ end
35
+
36
+ def volume()
37
+ val = settings_hash[:rs_vol]
38
+ (val.to_f * 100).to_i if val
39
+ end
40
+
41
+ def is_player_skin(value)
42
+ if settings_hash[:ds_skin] and skin_mapping[settings_hash[:ds_skin]] == value
43
+ return "color_selected"
44
+ end
45
+ end
46
+
47
+ def get_skin_code
48
+ skin_mapping[settings_hash[:ds_skin]] if settings_hash[:ds_skin]
49
+ end
50
+
51
+ def get_size_code
52
+ ds_w = settings_hash[:ds_w] || 0
53
+ ds_h = settings_hash[:ds_h] || 0
54
+ ds_plx = settings_hash[:ds_plx] || 0
55
+ ds_ply = settings_hash[:ds_ply] || 0
56
+
57
+ width = ds_w.to_i + ds_plx.to_i
58
+ height = ds_h.to_i + ds_ply.to_i
59
+ width.to_s + "x" + height.to_s
60
+ end
61
+
62
+ def get_no_playlist
63
+ "selected" if settings and not settings.include?("ds_plx=")
64
+ end
65
+
66
+ def get_vertical_playlist
67
+ "selected" if settings and settings.include?("ds_plx=") and settings_hash[:ds_plx].to_i == 0
68
+ end
69
+
70
+ def get_horizontal_playlist
71
+ "selected" if settings and settings.include?("ds_plx=") and settings_hash[:ds_plx].to_i > 0
72
+ end
73
+
74
+ def get_width_height(w,h)
75
+ "selected" if settings and settings.include?("ds_w=#{w}") and settings.include?("ds_h=#{h}")
76
+ end
77
+
78
+ def get_width_horizontal(plx)
79
+ "selected" if settings and settings.include?("ds_plx=#{plx}")
80
+ end
81
+
82
+ def get_height_vertical(ply)
83
+ "selected" if settings and settings.include?("ds_ply=#{ply}")
84
+ end
85
+
86
+ def set_settings_hash
87
+ @settings_hash = {}
88
+ unless settings.blank?
89
+ settings.split(/&/).each do |setting|
90
+ unless setting.blank?
91
+ key,value = setting.split(/=/)
92
+ @settings_hash[key.to_sym] = value
93
+ end
94
+ end
95
+ end
96
+ @settings_hash
97
+ end
98
+
99
+ def settings_hash
100
+ @settings_hash ||= set_settings_hash
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,28 @@
1
+ module OneScreen
2
+ class Playlist < OneScreenBase
3
+ schema do
4
+ # Readable + Writable Properties
5
+ string 'name', 'short_description', 'long_description', 'tags', 'last_published_date'
6
+ integer 'playlist_type_id'
7
+
8
+ # Readable Only Properties
9
+ # TODO: Unsupported type conversions Should be left as string
10
+ integer 'account_id', 'created_by', 'modified_by'
11
+ string 'row_version', 'created_at', 'modified_at',
12
+ end
13
+
14
+ validates :name, :presence => true, :length => {:minimum=>5,:maximum=>100}
15
+ validates :short_description, :length => {:maximum=>300}
16
+ validates :long_description, :length => {:maximum=>2000}
17
+ validates :tags, :length => {:maximum=>500}
18
+ validates :playlist_type_id, :presence => true, :numericality => true
19
+
20
+ public
21
+ def videos
22
+ self.media_sources if self.respond_to?(:media_sources)
23
+ end
24
+ def deploy_url
25
+ OneScreen::Config.get_value("onescreen", "cdn_path") + "#{self.account_id}/p/#{self.id}.xml"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ module OneScreen
2
+ class Signup < OneScreenBase
3
+
4
+ schema do
5
+ # Readable + Writable Properties
6
+ string 'username', 'account_name', 'password', 'email', 'confirmation_redirect_url'
7
+
8
+ # Readable Only Properties
9
+ # TODO: Unsupported type conversions Should be left as string
10
+ string 'created_at', 'guid'
11
+ end
12
+
13
+ validates :account_name, :presence => true, :length => {:minimum=>5,:maximum=>50}
14
+ validates :username, :presence => true, :length => {:minimum=>5,:maximum=>50}
15
+ validates :password, :presence => true, :length => {:minimum=>6}
16
+ validates :email, :presence => true, :length => {:minimum=>5,:maximum=>150}, :format => { :with=> /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
17
+ validates :confirmation_redirect_url, :length => {:minimum=>5,:maximum=>500}
18
+
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module OneScreen
2
+ class Site < OneScreenBase
3
+
4
+ schema do
5
+ # Readable + Writable Properties
6
+ string 'name', 'description', 'url',
7
+ 'account_relationship', 'rep_firm', 'has_video', 'only_video', 'embed_video', 'video_platform',
8
+ 'video_ad_sales', 'video_ad_networks', 'video_views', 'user_gen', 'register_required', 'privacy_policy',
9
+ 'terms_conditions', 'traffic_sources', 'traffic_measurment',
10
+ 'visitors_monthly_us', 'visitors_daily_us', 'page_views_us',
11
+ 'visitors_monthly_intl', 'visitors_daily_intl', 'page_views_intl',
12
+ 'auto_refresh', 'audience_gender', 'audience_age', 'audience_income'
13
+
14
+ # Readable Only Properties
15
+ # TODO: Unsupported type conversions Should be left as string
16
+ integer 'account_id', 'created_by', 'modified_by'
17
+ string 'row_version', 'created_at', 'modified_at'
18
+ end
19
+
20
+ validates :name, :presence => true, :length => {:minimum=>5,:maximum=>100}
21
+ validates :description, :length => {:maximum=>2000}
22
+ validates :url, :presence => true, :length => {:maximum=>250}
23
+
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ module OneScreen
2
+ class User < OneScreenBase
3
+
4
+ schema do
5
+ # Readable + Writable Properties
6
+ string 'user_name', 'first_name', 'last_name', 'email', 'title',
7
+ 'department', 'address1', 'address2', 'city', 'state', 'postal_code',
8
+ 'country', 'office_phone', 'mobile_phone', 'other_phone', 'fax'
9
+
10
+ # Readable Only Properties
11
+ # TODO: Unsupported type conversions Should be left as string
12
+ integer 'account_id', 'created_by', 'modified_by'
13
+ string 'row_version', 'created_at', 'modified_at'
14
+ end
15
+
16
+ validates :user_name, :presence => true, :length => {:minimum=>3,:maximum=>100}
17
+ validates :email, :presence => true, :length => {:minimum=>5,:maximum=>150}, :format => { :with=> /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
18
+ validates :department, :length => {:maximum=>50}
19
+ validates :address1, :length => {:maximum=>100}
20
+ validates :address2, :length => {:maximum=>100}
21
+ validates :city, :length => {:maximum=>100}
22
+ validates :state, :length => {:minimum=>2,:maximum=>75}
23
+ validates :postal_code, :length => {:minimum=>5,:maximum=>15}
24
+ validates :country, :length => {:minimum=>2,:maximum=>75}
25
+ validates :office_phone, :length => {:minimum=>9,:maximum=>100}
26
+ validates :mobile_phone, :length => {:minimum=>9,:maximum=>100}
27
+ validates :other_phone, :length => {:minimum=>9,:maximum=>100}
28
+ validates :fax, :length => {:minimum=>9,:maximum=>15}
29
+
30
+ public
31
+ def username
32
+ self.user_name
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: onescreen-api-client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - OneScreen Inc.
13
+ - Nirmit Patel
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-14 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activeresource
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ prerelease: false
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: shoulda
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 1
56
+ - 0
57
+ - 0
58
+ version: 1.0.0
59
+ type: :development
60
+ prerelease: false
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 1
71
+ - 5
72
+ - 1
73
+ version: 1.5.1
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: rcov
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
91
+ name: activeresource
92
+ requirement: &id006 !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ segments:
98
+ - 3
99
+ - 0
100
+ - 4
101
+ version: 3.0.4
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: *id006
105
+ description: This gem is designed to be used by consumers that wish to connect to the OneScreen API via a ruby plugin. The client that wishes to use this service will need to provide an api-key that will be supplied after registering with OneScreen.
106
+ email: npatel@onescreen.com
107
+ executables: []
108
+
109
+ extensions: []
110
+
111
+ extra_rdoc_files:
112
+ - ChangeLog.txt
113
+ - LICENSE.txt
114
+ - README.rdoc
115
+ files:
116
+ - lib/onescreen-api-client.rb
117
+ - lib/resources/account.rb
118
+ - lib/resources/asset.rb
119
+ - lib/resources/base.rb
120
+ - lib/resources/error.rb
121
+ - lib/resources/login.rb
122
+ - lib/resources/media_source.rb
123
+ - lib/resources/networks_affiliate.rb
124
+ - lib/resources/player.rb
125
+ - lib/resources/playlist.rb
126
+ - lib/resources/signup.rb
127
+ - lib/resources/site.rb
128
+ - lib/resources/user.rb
129
+ - ChangeLog.txt
130
+ - LICENSE.txt
131
+ - README.rdoc
132
+ has_rdoc: true
133
+ homepage: http://github.com/onescreen/api-client
134
+ licenses:
135
+ - MIT
136
+ post_install_message:
137
+ rdoc_options: []
138
+
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 462723471
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ segments:
156
+ - 0
157
+ version: "0"
158
+ requirements: []
159
+
160
+ rubyforge_project:
161
+ rubygems_version: 1.3.7
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: This gem is designed to be used by consumers that wish to connect to the OneScreen API via a ruby plugin.
165
+ test_files: []
166
+