modules/SNIP/SugarSNIP.php

Show: inherited
Table of Contents

\SugarSNIP

Package: SugarCRM

SNIP data handling implementation

Constants

Constant  SNIP_USER = 'SNIPuser'
Constant  OAUTH_KEY = 'SNIPOAuthKey'
Constant  DEFAULT_URL = 'http://ease.sugarcrm.com:20010/'

Properties

Propertypublicarray  $config= ''

Sugar configuration

Details
Type
array
Propertypublic\SugarSNIP  $instance= ''
static

Singleton instance

Details
Type
\SugarSNIP
Propertypublicmixed  $last_result= ''

Last REST call result

Details
Type
mixed
Propertyprotected\OAuthToken  $token= ''

SNIP OAuth token

Details
Type
\OAuthToken
Propertyprotected\User  $user= ''

SNIP user

Details
Type
\User

Methods

methodprotected__construct( ) : void

methodprotectedassignUser( \Email $email, string $username = null ) : void

Assign the email to proper user

Parameters
Name Type Description
$email \Email
$username string
methodpublicassignUserTeam( \SugarBean $email, string $userid ) : void
static

Assign user's private team to an email

Parameters
Name Type Description
$email \SugarBean

Email object

$userid string

User ID

methodpubliccallRest( string $name, string $params = array(), bool $json = false,  $connectionfailed = false ) : bool

Generic REST call to SNIP instance

Parameters
Name Type Description
$name string

function to call

$params string

parameters

$json bool

encode params as JSON in data var or send as query?

$connectionfailed
Returns
Type Description
bool Success?
methodprotectedcreateNote( array $data, \Email $email ) : void

Create a new Note object

Parameters
Name Type Description
$data array

Note data

$email \Email

parent email

methodprotectedcreateObject( \Email $email ) : void

Create objects from createdef definitions Example definition: $createdef['email@host.com']['Contacts'] = array( 'fields' => array( 'email1' => '{from_addr}', 'last_name' => '{from_name}', 'description' => 'created from {subject}', 'lead_source' => 'Email', ), ); Supported variables: - from - from_addr - from_name - subject - date - description - description_html - message_id - email_id

Parameters
Name Type Description
$email \Email
methodpubliccreatePurchaseURL(  $snipuser ) : string

Generate the url that the user can visit to purchase SNIP.

Parameters
Name Type Description
$snipuser
Returns
Type Description
string the generated url
methodprotectedcreateSnipToken( \User $user ) : void

Create oauth token for the SNIP user

Parameters
Name Type Description
$user \User
methodprotectedcreateSnipUser( ) : \User

Create user to use for SNIP imports

Returns
Type Description
\User
methodprotecteddeleteSnipTokens( \User $user ) : void

Create oauth token for the SNIP user

Parameters
Name Type Description
$user \User
methodpublicgetInstance( ) : \SugarSNIP
static

Get instance of the SNIP client

Returns
Type Description
\SugarSNIP SNIP client instance
methodprotectedgetKey( ) : void

methodpublicgetLastError( ) : string

Returns last error that happened to SNIP

Returns
Type Description
string
methodpublicgetLastResult( ) : mixed

Get result of the last REST call

Returns
Type Description
mixed
methodprotectedgetSnipConsumer( ) : \OAuthKey

Get consumer key belonging to SNIP

Returns
Type Description
\OAuthKey
methodpublicgetSnipEmail( ) : string

Get SNIP email address

Returns
Type Description
string
methodprotectedgetSnipToken( ) : \OAuthToken

Get OAuth token for SNIP user

Returns
Type Description
\OAuthToken
methodpublicgetSnipURL( ) : string

Get SNIP instance URL

Returns
Type Description
string
methodpublicgetSnipUser( ) : \User

Get user used for SNIP imports

Returns
Type Description
\User
methodpublicgetStatus( ) : array

Get status of the SNIP installation

Returns
Type Description
array Returns an associative array ('status'=>string, 'message'=>string|null), with 'status' as one of the following: - purchased (instance has snip license) - notpurchased (instance does not have snip license) - down (snip server unresponsive) - purchased_error (instance has snip license, server is not down, but server detects something is wrong). Iff 'status' is 'purchased_error', 'message' will be the error returned by the server. Otherwise $message will be NULL.
methodpublicgetURL( ) : string

Get instance callback URL

Returns
Type Description
string
methodpublicimportEmail( array $email ) : void

Imports an email from the SNIP serice

Parameters
Name Type Description
$email array
methodpublicisActive( ) : bool

Check if SNIP interface is active

Returns
Type Description
bool
methodprotectedprocessEmailAttachment(  $data,  $email ) : void

Save a snip email attachment and associated it to a parent email. Content is base64 encoded.

Parameters
Name Type Description
$data
$email
methodpublicregisterSnip( ) : mixed

Register this instance with SNIP server

Returns
Type Description
mixed server response
methodprotectedrelateRecords( \Email $e ) : void

Relate records to this email

Parameters
Name Type Description
$e \Email
methodpublicsetClient( \SugarHttpClient $client ) : void

Set client to talk to SNIP

Parameters
Name Type Description
$client \SugarHttpClient
methodpublicsetSnipEmail( string $email ) : void

Set SNIP email address

Parameters
Name Type Description
$email string
methodpublicsetSnipURL( string $url ) : void

Set SNIP instance URL.

Parameters
Name Type Description
$url string
methodprotectedsplitEmailAddress( \Email $email, string $addr ) : array

Split email address into name & address part

Parameters
Name Type Description
$email \Email
$addr string
Returns
Type Description
array
methodpublicunregisterSnip( ) : mixed

Unregister SNIP from server

Returns
Type Description
mixed server response
Documentation was generated by DocBlox 0.18.1.