Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## MATLAB PLOTLY API WRAPPER 2.1.6
## MATLAB PLOTLY API WRAPPER 2.1.7

### NUTSHELL:

Expand Down
2 changes: 1 addition & 1 deletion plotly/plotly_aux/plotly_version.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function version = plotly_version()
version = '2.1.6';
version = '2.1.7';
end
12 changes: 12 additions & 0 deletions plotly/plotly_user_aux/saveplotlyconfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain)
% Plotly config info are saved as JSON strings
% in ~/.plotly/.config

% catch missing input arguments
if nargin < 1
error('plotly:saveconfig', ...
['Incorrect number of inputs. Please save your configuration ', ...
'as follows: >> saveplotlyconfig(plotly_domain,', ...
'[optional]plotly_streaming_domain)']);
end

% if the config file exists, then load it up
try
config = loadplotlyconfig();
Expand Down Expand Up @@ -37,12 +45,16 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain)
'chris@plot.ly for support.']);
end

% get user credenitals
[username, api_key] = signin;

switch nargin
case 1
config.plotly_domain = plotly_domain;
signin(username, api_key, plotly_domain);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the kicker

case 2
config.plotly_domain = plotly_domain;
signin(username, api_key, plotly_domain);
config.plotly_streaming_domain= plotly_streaming_domain;
otherwise %if neither endpoints are specified, no worries!
end
Expand Down
14 changes: 11 additions & 3 deletions plotly/plotly_user_aux/saveplotlycredentials.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ function saveplotlycredentials(username, api_key, stream_ids)
% Plotly credentials are saved as JSON strings
% in ~/.plotly/.credentials

% catch missing input arguments
if nargin < 2
error('plotly:savecredentials', ...
['Incorrect number of inputs. Please save your credentials ', ...
'as follows: >> saveplotlycredentials(username, api_key,', ...
'[optional]stream_ids)']);
end

% if the credentials file exists, then load it up
try
creds = loadplotlycredentials();
Expand Down Expand Up @@ -45,9 +53,6 @@ function saveplotlycredentials(username, api_key, stream_ids)
creds.username = username;
creds.api_key = api_key;
creds.stream_ids = stream_ids;
otherwise %need to specify both the username and api_key
error('plotly:savecredentials',...
'Please specify your username and api_key');
end

creds_string = m2json(creds);
Expand All @@ -56,4 +61,7 @@ function saveplotlycredentials(username, api_key, stream_ids)
fprintf(fileIDCred,'%s',creds_string);
fclose(fileIDCred);

%signin using newly saved credentials
signin(username, api_key);

end
26 changes: 19 additions & 7 deletions plotlysetup.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ function plotlysetup(username, api_key, varargin)

try %save user credentials
fprintf('Saving username/api_key credentials ... ');
saveplotlycredentials(username,api_key);

%update: as of v.2.1.7, This also signs in the user
saveplotlycredentials(username, api_key);

%worked!
fprintf('Done\n');
catch exception %writing credentials file permission problem catch...
Expand Down Expand Up @@ -168,13 +171,19 @@ function plotlysetup(username, api_key, varargin)

if strcmp(varargin{n},'stream_ids')
fprintf('Saving stream_ids credentials ... ');
saveplotlycredentials(username,api_key,varargin{n+1});

%update: as of v.2.1.7, This also signs in the user
saveplotlycredentials(username, api_key, varargin{n+1});

%worked!
fprintf('Done\n');
end
if strcmp(varargin{n},'plotly_domain')
fprintf('Saving plotly_domain configuration ... ');

%update: as of v.2.1.7, This also signs in the user
saveplotlyconfig(varargin{n+1});

%worked!
fprintf('Done\n');
end
Expand All @@ -185,7 +194,10 @@ function plotlysetup(username, api_key, varargin)
catch
config.plotly_domain = '';
end

%update: as of v.2.1.7, This also signs in the user
saveplotlyconfig(config.plotly_domain,varargin{n+1});

%worked!
fprintf('Done\n');
end
Expand All @@ -195,9 +207,6 @@ function plotlysetup(username, api_key, varargin)
fprintf(['\n\n' exception.identifier exception.message '\n\n']);
end

%sign in the user
signin(username,api_key);

%greet the people!
fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n')

Expand All @@ -210,7 +219,10 @@ function plotlysetup(username, api_key, varargin)
'the Plotly folder to your MATLAB path manually by running: \n\n',...
'>> plotly_path = fullfile(pwd, ''plotly'')\n',...
'>> addpath(genpath(plotly_path))\n\n',...
'Questions? Chuck@plotly'];

'You can save your credentials by running:\n\n', ...
'>>saveplotlycredentials(''your_username'', ''your_api_key'')\n\n',...
'You can save your domain configuration by running:\n\n',...
'>>saveplotlyconfig(''your_base_domain'')\n\n',...
'Questions? Chuck@plotly\n\n'];
end