Skip to content

Commit bb62996

Browse files
author
Rob Race
committed
Merge pull request #3 from TraxTechnologies/v9
Changes to support Tableau 9
2 parents 9b3624d + 81e88ea commit bb62996

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ end
9393
``` ruby
9494

9595
@workbooks = client.workbooks.all(site_id: 'site-id')
96+
@workbooks = client.workbooks.all(site_id: 'site-id', is_owner: boolean, page_size: 'page-size', page_number: 'page-number')
9697

9798
@workbook = client.workbooks.find(id: 'workbook-id', site_id: 'site-id', include_views: true)
9899

lib/tableau_ruby/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def sign_in(user=nil)
6666
xml.tsRequest do
6767
xml.credentials(name: @admin_name, password: @admin_password) do
6868
xml.user(name: user) if user
69-
xml.site
69+
xml.site(contentUrl: @site_name)
7070
end
7171
end
7272
end

lib/tableau_ruby/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module TableauRuby
2-
VERSION = '0.0.1' unless defined?(self::VERSION)
2+
VERSION = '0.1.0' unless defined?(self::VERSION)
33

44
def self.version
55
VERSION

lib/tableau_ruby/workbook.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def all(params={})
1313

1414
resp = @client.conn.get "/api/2.0/sites/#{params[:site_id]}/users/#{params[:user_id]}/workbooks" do |req|
1515
req.params['getThumbnails'] = params[:include_images] if params[:include_images]
16+
req.params['isOwner'] = params[:is_owner] if params[:is_owner]
17+
req.params['page-size'] = params[:page_size] if params[:page_size]
18+
req.params['page-number'] = params[:page_number] if params[:page_number]
1619
req.headers['X-Tableau-Auth'] = @client.token if @client.token
1720
end
1821

@@ -26,7 +29,7 @@ def all(params={})
2629
end
2730

2831
doc.css("workbook").each do |w|
29-
workbook = {id: w["id"], name: w["name"]}
32+
workbook = {id: w["id"], name: w["name"], content_url: w["contentUrl"]}
3033

3134
if params[:include_images]
3235
resp = @client.conn.get("/api/2.0/sites/#{params[:site_id]}/workbooks/#{w['id']}/previewImage") do |req|
@@ -62,7 +65,7 @@ def find(workbook)
6265
data = {workbook: {}}
6366
Nokogiri::XML(resp.body).css("workbook").each do |w|
6467

65-
wkbk = {id: w["id"], name: w["name"], description: w['description']}
68+
wkbk = {id: w["id"], name: w["name"], content_url: w['contentUrl']}
6669

6770
if workbook[:include_views]
6871
wkbk[:views] = include_views(site_id: workbook[:site_id], id: workbook[:id])
@@ -76,7 +79,7 @@ def find(workbook)
7679

7780
# TODO: Refactor this is duplicate in all method. Also, there are many, many places that are begging to be DRYer.
7881
def preview_image(workbook)
79-
resp = @client.conn.get("/api/2.0/sites/#{params[:site_id]}/workbooks/#{workbook[:id]}/previewImage") do |req|
82+
resp = @client.conn.get("/api/2.0/sites/#{@client.site_id}/workbooks/#{workbook[:id]}/previewImage") do |req|
8083
req.headers['X-Tableau-Auth'] = @client.token if @client.token
8184
end
8285

@@ -90,15 +93,18 @@ def preview_image(workbook)
9093
private
9194

9295
def include_views(params)
96+
9397
resp = @client.conn.get("/api/2.0/sites/#{params[:site_id]}/workbooks/#{params[:id]}/views") do |req|
9498
req.headers['X-Tableau-Auth'] = @client.token if @client.token
9599
end
96100

101+
views = []
102+
97103
Nokogiri::XML(resp.body).css("view").each do |v|
98-
(@views ||= []) << {id: v['id'], name: v['name']}
104+
views << {id: v['id'], name: v['name'], content_url: v['contentUrl']}
99105
end
100106

101-
@views
107+
views
102108
end
103109

104110
end

0 commit comments

Comments
 (0)