| 1 | package Sash::Plugin::Base; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | our $VERSION = '1.01'; | ||
| 7 | |||
| 8 | use Carp; | ||
| 9 | |||
| 10 | my $_client; | ||
| 11 | my $_username; | ||
| 12 | my $_password; | ||
| 13 | my $_endpoint; | ||
| 14 | my $_vendor; | ||
| 15 | my $_database; | ||
| 16 | my $_hostname; | ||
| 17 | |||
| 18 | sub enable { | ||
| 19 | my $class = shift; | ||
| 20 | my $args = shift; | ||
| 21 | |||
| 22 | # Make sure we have the correct parameters defined so that we can connect | ||
| 23 | # to salesforce | ||
| 24 | croak $class . '->enable Invalid Invocation - args must be a hash ref' unless ref $args eq 'HASH'; | ||
| 25 | |||
| 26 | croak $class . '->enable Invalid Invocation - missing username, password, endpoint or terminal' | ||
| 27 | unless defined $args->{username} && defined $args->{password} && defined $args->{endpoint}; | ||
| 28 | |||
| 29 | # Define our highlander constants that are referenced by the show command. | ||
| 30 | $_username = $args->{username}; | ||
| 31 | $_password = $args->{password}; | ||
| 32 | $_endpoint = $args->{endpoint}; | ||
| 33 | |||
| 34 | eval { | ||
| 35 | $class->connect( $args ); | ||
| 36 | }; if ( $@ ) { | ||
| 37 | croak "Unable to connect to datasource: $@"; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | sub connect { | ||
| 42 | croak __PACKAGE__ . '->connect - Can not invoke abstract class method directly'; | ||
| 43 | } | ||
| 44 | |||
| 45 | sub username { | ||
| 46 | my $class = shift; | ||
| 47 | return $_username = ( shift || $_username ); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub password { | ||
| 51 | my $class = shift; | ||
| 52 | return $_password = ( shift || $_password ); | ||
| 53 | } | ||
| 54 | |||
| 55 | sub endpoint { | ||
| 56 | my $class = shift; | ||
| 57 | return $_endpoint = ( shift || $_endpoint ); | ||
| 58 | } | ||
| 59 | |||
| 60 | sub client { | ||
| 61 | my $class = shift; | ||
| 62 | return $_client = ( shift || $_client ); | ||
| 63 | } | ||
| 64 | |||
| 65 | sub vendor { | ||
| 66 | my $class = shift; | ||
| 67 | return $_vendor = ( shift || $_vendor ); | ||
| 68 | } | ||
| 69 | |||
| 70 | sub database { | ||
| 71 | my $class = shift; | ||
| 72 | return $_database = ( shift || $_database ); | ||
| 73 | } | ||
| 74 | |||
| 75 | sub hostname { | ||
| 76 | my $class = shift; | ||
| 77 | return $_hostname = ( shift || $_hostname ); | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | 1; |