Class: ViewAPI
- Inherits:
-
Object
- Object
- ViewAPI
- Defined in:
- lib/zoho_analytics_client.rb
Overview
ViewAPI contains view level operations.
Instance Method Summary collapse
-
#add_aggregate_formula(formula_name, expression, config = {}) ⇒ String
Adds an aggregate formula to the table.
-
#add_column(column_name, data_type, config = {}) ⇒ Integer
Add a column to the view.
-
#add_favorite ⇒ Object
Adds a specified view as favorite.
-
#add_formula_column(formula_name, expression, config = {}) ⇒ String
Adds a formula column to the table.
-
#add_lookup(column_id, ref_view_id, ref_column_id, config = {}) ⇒ Object
Adds a lookup in the specified child table.
-
#add_row(column_values, config = {}) ⇒ Hash
Adds a single row in the specified table.
-
#auto_analyse(config = {}) ⇒ Object
Auto generate reports.
-
#auto_analyse_column(column_id, config = {}) ⇒ Object
Auto generates reports for the specified column.
-
#copy_formulas(formula_names, dest_workspace_id, config = {}, dest_org_id = nil) ⇒ Object
Copy formulas to another workspace or view.
-
#create_private_url(config = {}) ⇒ String
Create private URL for the view.
-
#create_similar_views(ref_view_id, folder_id, config = {}) ⇒ Object
Create similar reports based on a reference view.
-
#delete(config = {}) ⇒ Object
Delete a specified view in the workspace.
-
#delete_aggregate_formula(formula_id, config = {}) ⇒ Object
Deletes an aggregate formula.
-
#delete_column(column_id, config = {}) ⇒ Object
Deletes a specified column in the table.
-
#delete_formula_column(formula_id, config = {}) ⇒ Object
Deletes a formula column.
-
#delete_row(criteria, config = {}) ⇒ String
Deletes rows in the specified table.
-
#edit_aggregate_formula(formula_id, expression, config = {}) ⇒ Object
Edits an aggregate formula.
-
#edit_formula_column(formula_id, expression, config = {}) ⇒ Object
Edits a formula column.
-
#get_aggregate_formulas ⇒ Array<Hash>
Returns list of all aggregate formulas for the table.
-
#get_column_dependents(column_id) ⇒ Hash
Returns list of dependent views and formulas for the specified column.
-
#get_embed_url(config = {}) ⇒ String
Get embed URL of the view.
-
#get_formula_columns ⇒ Array<Hash>
Returns list of all formula columns for the table.
-
#get_last_import_details ⇒ Hash
Returns last import details of the view.
-
#get_my_permissions ⇒ Hash
Get user permissions for the view.
-
#get_private_url(config = {}) ⇒ String
Get private URL of the view.
-
#get_publish_configurations ⇒ Hash
Get publish configurations of the view.
-
#get_table_metadata ⇒ Hash
Returns metadata details like columns present for the specified table.
-
#get_view_dependents ⇒ Array<Hash>
Returns the dependent views of this view.
-
#get_view_url(config = {}) ⇒ String
Get the URL to access the view.
-
#hide_columns(column_ids) ⇒ Object
Hide columns in the view.
-
#initialize(ac, org_id, workspace_id, view_id) ⇒ ViewAPI
constructor
A new instance of ViewAPI.
-
#make_view_public(config = {}) ⇒ String
Make the view publicly accessible.
-
#refetch_data(config = {}) ⇒ Object
Syncs data from the available data source for the view.
-
#remove_favorite ⇒ Object
Removes a specified view from favorites.
-
#remove_lookup(column_id, config = {}) ⇒ Object
Removes the lookup for the specified column in the table.
-
#remove_private_access ⇒ Object
Remove private access for the view.
-
#remove_public_access ⇒ Object
Remove public access for the view.
-
#rename(view_name, config = {}) ⇒ Object
Rename a specified view in the workspace.
-
#rename_column(column_id, column_name, config = {}) ⇒ Object
Renames a specified column in the table.
-
#reorder_columns(column_ids, config = {}) ⇒ Object
Updates the column order of the current table.
-
#save_as(new_view_name, config = {}) ⇒ Integer
Copy a specified view within the workspace.
-
#show_columns(column_ids) ⇒ Object
Show hidden columns in the view.
-
#sort_data_by_columns(columns = nil, sort_order = nil, reset_sort = false, config = {}) ⇒ Object
Sorts the data in the current table based on the specified columns.
-
#update_publish_configurations(config = {}) ⇒ Object
Update publish configurations of the view.
-
#update_row(column_values, criteria, config = {}) ⇒ Hash
Updates rows in the specified table.
-
#update_shared_details(config = {}) ⇒ Object
Updates the shared details of the specified view.
Constructor Details
#initialize(ac, org_id, workspace_id, view_id) ⇒ ViewAPI
Returns a new instance of ViewAPI.
1779 1780 1781 1782 1783 |
# File 'lib/zoho_analytics_client.rb', line 1779 def initialize(ac, org_id, workspace_id, view_id) @ac = ac @endpoint = "/restapi/v2/workspaces/#{workspace_id}/views/#{view_id}" @request_headers = { "ZANALYTICS-ORGID" => org_id } end |
Instance Method Details
#add_aggregate_formula(formula_name, expression, config = {}) ⇒ String
Adds an aggregate formula to the table.
2111 2112 2113 2114 2115 2116 2117 |
# File 'lib/zoho_analytics_client.rb', line 2111 def add_aggregate_formula(formula_name, expression, config = {}) config["formulaName"] = formula_name config["expression"] = expression endpoint = "#{@endpoint}/aggregateformulas" response = @ac.send_api_request("POST", endpoint, config, @request_headers) response["formulaId"] end |
#add_column(column_name, data_type, config = {}) ⇒ Integer
Add a column to the view.
1939 1940 1941 1942 1943 1944 1945 |
# File 'lib/zoho_analytics_client.rb', line 1939 def add_column(column_name, data_type, config = {}) config["columnName"] = column_name config["dataType"] = data_type endpoint = "#{@endpoint}/columns" response = @ac.send_api_request("POST", endpoint, config, @request_headers) response["columnId"].to_i end |
#add_favorite ⇒ Object
Adds a specified view as favorite.
1825 1826 1827 1828 |
# File 'lib/zoho_analytics_client.rb', line 1825 def add_favorite endpoint = "#{@endpoint}/favorite" @ac.send_api_request("POST", endpoint, nil, @request_headers) end |
#add_formula_column(formula_name, expression, config = {}) ⇒ String
Adds a formula column to the table.
2072 2073 2074 2075 2076 2077 2078 |
# File 'lib/zoho_analytics_client.rb', line 2072 def add_formula_column(formula_name, expression, config = {}) config["formulaName"] = formula_name config["expression"] = expression endpoint = "#{@endpoint}/formulacolumns" response = @ac.send_api_request("POST", endpoint, config, @request_headers) response["formulaId"] end |
#add_lookup(column_id, ref_view_id, ref_column_id, config = {}) ⇒ Object
Adds a lookup in the specified child table.
2021 2022 2023 2024 2025 2026 |
# File 'lib/zoho_analytics_client.rb', line 2021 def add_lookup(column_id, ref_view_id, ref_column_id, config = {}) config["referenceViewId"] = ref_view_id config["referenceColumnId"] = ref_column_id endpoint = "#{@endpoint}/columns/#{column_id}/lookup" @ac.send_api_request("POST", endpoint, config, @request_headers) end |
#add_row(column_values, config = {}) ⇒ Hash
Adds a single row in the specified table.
1967 1968 1969 1970 1971 1972 |
# File 'lib/zoho_analytics_client.rb', line 1967 def add_row(column_values, config = {}) config["columns"] = column_values endpoint = "#{@endpoint}/rows" response = @ac.send_api_request("POST", endpoint, config, @request_headers) response end |
#auto_analyse(config = {}) ⇒ Object
Auto generate reports.
1849 1850 1851 1852 |
# File 'lib/zoho_analytics_client.rb', line 1849 def auto_analyse(config = {}) endpoint = "#{@endpoint}/autoanalyse" @ac.send_api_request("POST", endpoint, config, @request_headers) end |
#auto_analyse_column(column_id, config = {}) ⇒ Object
Auto generates reports for the specified column.
2039 2040 2041 2042 |
# File 'lib/zoho_analytics_client.rb', line 2039 def auto_analyse_column(column_id, config = {}) endpoint = "#{@endpoint}/columns/#{column_id}/autoanalyse" @ac.send_api_request("POST", endpoint, config, @request_headers) end |
#copy_formulas(formula_names, dest_workspace_id, config = {}, dest_org_id = nil) ⇒ Object
Copy formulas to another workspace or view.
1815 1816 1817 1818 1819 1820 1821 1822 |
# File 'lib/zoho_analytics_client.rb', line 1815 def copy_formulas(formula_names, dest_workspace_id, config = {}, dest_org_id = nil) config["formulaColumnNames"] = formula_names config["destWorkspaceId"] = dest_workspace_id endpoint = "#{@endpoint}/formulas/copy" headers = @request_headers.dup headers["ZANALYTICS-DEST-ORGID"] = dest_org_id if dest_org_id @ac.send_api_request("POST", endpoint, config, headers) end |
#create_private_url(config = {}) ⇒ String
Create private URL for the view.
1892 1893 1894 1895 1896 |
# File 'lib/zoho_analytics_client.rb', line 1892 def create_private_url(config = {}) endpoint = "#{@endpoint}/publish/privatelink" response = @ac.send_api_request("POST", endpoint, config, @request_headers) response["privateUrl"] end |
#create_similar_views(ref_view_id, folder_id, config = {}) ⇒ Object
Create similar reports based on a reference view.
1840 1841 1842 1843 1844 1845 |
# File 'lib/zoho_analytics_client.rb', line 1840 def create_similar_views(ref_view_id, folder_id, config = {}) config["referenceViewId"] = ref_view_id config["folderId"] = folder_id endpoint = "#{@endpoint}/similarviews" @ac.send_api_request("POST", endpoint, config, @request_headers) end |
#delete(config = {}) ⇒ Object
Delete a specified view in the workspace.
1795 1796 1797 |
# File 'lib/zoho_analytics_client.rb', line 1795 def delete(config = {}) @ac.send_api_request("DELETE", @endpoint, config, @request_headers) end |
#delete_aggregate_formula(formula_id, config = {}) ⇒ Object
Deletes an aggregate formula.
2132 2133 2134 2135 |
# File 'lib/zoho_analytics_client.rb', line 2132 def delete_aggregate_formula(formula_id, config = {}) endpoint = "#{@endpoint}/aggregateformulas/#{formula_id}" @ac.send_api_request("DELETE", endpoint, config, @request_headers) end |
#delete_column(column_id, config = {}) ⇒ Object
Deletes a specified column in the table.
2011 2012 2013 2014 |
# File 'lib/zoho_analytics_client.rb', line 2011 def delete_column(column_id, config = {}) endpoint = "#{@endpoint}/columns/#{column_id}" @ac.send_api_request("DELETE", endpoint, config, @request_headers) end |
#delete_formula_column(formula_id, config = {}) ⇒ Object
Deletes a formula column.
2093 2094 2095 2096 |
# File 'lib/zoho_analytics_client.rb', line 2093 def delete_formula_column(formula_id, config = {}) endpoint = "#{@endpoint}/formulacolumns/#{formula_id}" @ac.send_api_request("DELETE", endpoint, config, @request_headers) end |
#delete_row(criteria, config = {}) ⇒ String
Deletes rows in the specified table.
1991 1992 1993 1994 1995 1996 |
# File 'lib/zoho_analytics_client.rb', line 1991 def delete_row(criteria, config = {}) config["criteria"] = criteria unless criteria.nil? endpoint = "#{@endpoint}/rows" response = @ac.send_api_request("DELETE", endpoint, config, @request_headers) response["deletedRows"] end |
#edit_aggregate_formula(formula_id, expression, config = {}) ⇒ Object
Edits an aggregate formula.
2123 2124 2125 2126 2127 |
# File 'lib/zoho_analytics_client.rb', line 2123 def edit_aggregate_formula(formula_id, expression, config = {}) config["expression"] = expression endpoint = "#{@endpoint}/aggregateformulas/#{formula_id}" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#edit_formula_column(formula_id, expression, config = {}) ⇒ Object
Edits a formula column.
2084 2085 2086 2087 2088 |
# File 'lib/zoho_analytics_client.rb', line 2084 def edit_formula_column(formula_id, expression, config = {}) config["expression"] = expression endpoint = "#{@endpoint}/formulacolumns/#{formula_id}" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#get_aggregate_formulas ⇒ Array<Hash>
Returns list of all aggregate formulas for the table.
2100 2101 2102 2103 2104 |
# File 'lib/zoho_analytics_client.rb', line 2100 def get_aggregate_formulas endpoint = "#{@endpoint}/aggregateformulas" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response["aggregateFormulas"] end |
#get_column_dependents(column_id) ⇒ Hash
Returns list of dependent views and formulas for the specified column.
2150 2151 2152 2153 2154 |
# File 'lib/zoho_analytics_client.rb', line 2150 def get_column_dependents(column_id) endpoint = "#{@endpoint}/columns/#{column_id}/dependents" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response end |
#get_embed_url(config = {}) ⇒ String
Get embed URL of the view.
1874 1875 1876 1877 1878 |
# File 'lib/zoho_analytics_client.rb', line 1874 def (config = {}) endpoint = "#{@endpoint}/publish/embed" response = @ac.send_api_request("GET", endpoint, config, @request_headers) response["embedUrl"] end |
#get_formula_columns ⇒ Array<Hash>
Returns list of all formula columns for the table.
2061 2062 2063 2064 2065 |
# File 'lib/zoho_analytics_client.rb', line 2061 def get_formula_columns endpoint = "#{@endpoint}/formulacolumns" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response["formulaColumns"] end |
#get_last_import_details ⇒ Hash
Returns last import details of the view.
2053 2054 2055 2056 2057 |
# File 'lib/zoho_analytics_client.rb', line 2053 def get_last_import_details endpoint = "#{@endpoint}/importdetails" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response end |
#get_my_permissions ⇒ Hash
Get user permissions for the view.
1856 1857 1858 1859 1860 |
# File 'lib/zoho_analytics_client.rb', line 1856 def endpoint = "#{@endpoint}/share/userpermissions" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response["permissions"] end |
#get_private_url(config = {}) ⇒ String
Get private URL of the view.
1883 1884 1885 1886 1887 |
# File 'lib/zoho_analytics_client.rb', line 1883 def get_private_url(config = {}) endpoint = "#{@endpoint}/publish/privatelink" response = @ac.send_api_request("GET", endpoint, config, @request_headers) response["privateUrl"] end |
#get_publish_configurations ⇒ Hash
Get publish configurations of the view.
1921 1922 1923 1924 1925 |
# File 'lib/zoho_analytics_client.rb', line 1921 def get_publish_configurations endpoint = "#{@endpoint}/publish/config" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response end |
#get_table_metadata ⇒ Hash
Returns metadata details like columns present for the specified table.
2170 2171 2172 2173 2174 |
# File 'lib/zoho_analytics_client.rb', line 2170 def endpoint = "#{@endpoint}/metadata" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response end |
#get_view_dependents ⇒ Array<Hash>
Returns the dependent views of this view.
2139 2140 2141 2142 2143 |
# File 'lib/zoho_analytics_client.rb', line 2139 def get_view_dependents endpoint = "#{@endpoint}/dependents" response = @ac.send_api_request("GET", endpoint, nil, @request_headers) response["views"] end |
#get_view_url(config = {}) ⇒ String
Get the URL to access the view.
1865 1866 1867 1868 1869 |
# File 'lib/zoho_analytics_client.rb', line 1865 def get_view_url(config = {}) endpoint = "#{@endpoint}/publish" response = @ac.send_api_request("GET", endpoint, config, @request_headers) response["viewUrl"] end |
#hide_columns(column_ids) ⇒ Object
Hide columns in the view.
1949 1950 1951 1952 1953 |
# File 'lib/zoho_analytics_client.rb', line 1949 def hide_columns(column_ids) config = { "columnIds" => column_ids } endpoint = "#{@endpoint}/columns/hide" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#make_view_public(config = {}) ⇒ String
Make the view publicly accessible.
1907 1908 1909 1910 1911 |
# File 'lib/zoho_analytics_client.rb', line 1907 def make_view_public(config = {}) endpoint = "#{@endpoint}/publish/public" response = @ac.send_api_request("POST", endpoint, config, @request_headers) response["publicUrl"] end |
#refetch_data(config = {}) ⇒ Object
Syncs data from the available data source for the view.
2046 2047 2048 2049 |
# File 'lib/zoho_analytics_client.rb', line 2046 def refetch_data(config = {}) endpoint = "#{@endpoint}/sync" @ac.send_api_request("POST", endpoint, config, @request_headers) end |
#remove_favorite ⇒ Object
Removes a specified view from favorites.
1831 1832 1833 1834 |
# File 'lib/zoho_analytics_client.rb', line 1831 def remove_favorite endpoint = "#{@endpoint}/favorite" @ac.send_api_request("DELETE", endpoint, nil, @request_headers) end |
#remove_lookup(column_id, config = {}) ⇒ Object
Removes the lookup for the specified column in the table.
2031 2032 2033 2034 |
# File 'lib/zoho_analytics_client.rb', line 2031 def remove_lookup(column_id, config = {}) endpoint = "#{@endpoint}/columns/#{column_id}/lookup" @ac.send_api_request("DELETE", endpoint, config, @request_headers) end |
#remove_private_access ⇒ Object
Remove private access for the view.
1899 1900 1901 1902 |
# File 'lib/zoho_analytics_client.rb', line 1899 def remove_private_access endpoint = "#{@endpoint}/publish/privatelink" @ac.send_api_request("DELETE", endpoint, nil, @request_headers) end |
#remove_public_access ⇒ Object
Remove public access for the view.
1914 1915 1916 1917 |
# File 'lib/zoho_analytics_client.rb', line 1914 def remove_public_access endpoint = "#{@endpoint}/publish/public" @ac.send_api_request("DELETE", endpoint, nil, @request_headers) end |
#rename(view_name, config = {}) ⇒ Object
Rename a specified view in the workspace.
1788 1789 1790 1791 |
# File 'lib/zoho_analytics_client.rb', line 1788 def rename(view_name, config = {}) config["viewName"] = view_name @ac.send_api_request("PUT", @endpoint, config, @request_headers) end |
#rename_column(column_id, column_name, config = {}) ⇒ Object
Renames a specified column in the table.
2002 2003 2004 2005 2006 |
# File 'lib/zoho_analytics_client.rb', line 2002 def rename_column(column_id, column_name, config = {}) config["columnName"] = column_name endpoint = "#{@endpoint}/columns/#{column_id}" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#reorder_columns(column_ids, config = {}) ⇒ Object
Updates the column order of the current table.
2182 2183 2184 2185 2186 |
# File 'lib/zoho_analytics_client.rb', line 2182 def reorder_columns(column_ids, config = {}) config["columns"] = column_ids endpoint = "#{@endpoint}/columns/reorder" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#save_as(new_view_name, config = {}) ⇒ Integer
Copy a specified view within the workspace.
1803 1804 1805 1806 1807 1808 |
# File 'lib/zoho_analytics_client.rb', line 1803 def save_as(new_view_name, config = {}) config["viewName"] = new_view_name endpoint = "#{@endpoint}/saveas" response = @ac.send_api_request("POST", endpoint, config, @request_headers) response["viewId"].to_i end |
#show_columns(column_ids) ⇒ Object
Show hidden columns in the view.
1957 1958 1959 1960 1961 |
# File 'lib/zoho_analytics_client.rb', line 1957 def show_columns(column_ids) config = { "columnIds" => column_ids } endpoint = "#{@endpoint}/columns/show" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#sort_data_by_columns(columns = nil, sort_order = nil, reset_sort = false, config = {}) ⇒ Object
Sorts the data in the current table based on the specified columns.
2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 |
# File 'lib/zoho_analytics_client.rb', line 2197 def sort_data_by_columns(columns = nil, sort_order = nil, reset_sort = false, config = {}) if reset_sort config["resetSort"] = "true" else config["sortOrder"] = sort_order config["columns"] = columns end endpoint = "#{@endpoint}/data/sort" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#update_publish_configurations(config = {}) ⇒ Object
Update publish configurations of the view.
1929 1930 1931 1932 |
# File 'lib/zoho_analytics_client.rb', line 1929 def update_publish_configurations(config = {}) endpoint = "#{@endpoint}/publish/config" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |
#update_row(column_values, criteria, config = {}) ⇒ Hash
Updates rows in the specified table.
1979 1980 1981 1982 1983 1984 1985 |
# File 'lib/zoho_analytics_client.rb', line 1979 def update_row(column_values, criteria, config = {}) config["columns"] = column_values config["criteria"] = criteria unless criteria.nil? endpoint = "#{@endpoint}/rows" response = @ac.send_api_request("PUT", endpoint, config, @request_headers) response end |
#update_shared_details(config = {}) ⇒ Object
Updates the shared details of the specified view.
2160 2161 2162 2163 |
# File 'lib/zoho_analytics_client.rb', line 2160 def update_shared_details(config = {}) endpoint = "#{@endpoint}/share" @ac.send_api_request("PUT", endpoint, config, @request_headers) end |