Documentation ¶
Index ¶
- Constants
- func ClassicTime(s string) (t time.Time, err error)
- func EngageDate(s string) string
- func EngageTimestamp(s string) string
- func FixCrit(c string) string
- func ShortDate(s string) string
- type API
- func (a *API) Authenticate(c CredData) error
- func (a *API) Chapter() Table
- func (a *API) Donation() Table
- func (a *API) EmailBlast() Table
- func (a *API) Get(u string) (*http.Response, []byte, error)
- func (a *API) Groups() Table
- func (a *API) GroupsSupporters() Table
- func (a *API) NewTable(n string) Table
- func (a *API) Org() Table
- func (a *API) Publish() Table
- func (a *API) Supporter() Table
- func (a *API) SupporterDonation() Table
- func (a *API) SupporterGroups() Table
- func (a *API) Unsubscribe() Table
- type AuthStatus
- type Chapter
- type CredData
- type DeleteStatus
- type Field
- type FieldList
- type MapList
- type Organization
- type Results
- type SalsaTimestamp
- type Table
- func (t *Table) Count(c string) (string, error)
- func (t *Table) Delete(key string, target interface{}) error
- func (t *Table) Describe() (f FieldList, err error)
- func (t *Table) LeftJoin(offset int32, count int, crit string, target interface{}) error
- func (t *Table) LeftJoinMap(offset int32, count int, crit string) ([]map[string]string, error)
- func (t *Table) LeftJoinRaw(offset int32, count int, crit string) ([]byte, error)
- func (t *Table) Many(offset int32, count int, crit string, target interface{}) error
- func (t *Table) ManyMap(offset int32, count int, crit string) ([]map[string]string, error)
- func (t *Table) ManyMapTagged(offset int32, count int, crit string, tag string) ([]map[string]string, error)
- func (t *Table) ManyRaw(offset int32, count int, crit string) ([]byte, error)
- func (t *Table) ManyRawTagged(offset int32, count int, crit string, tag string) ([]byte, error)
- func (t *Table) ManyTagged(offset int32, count int, crit string, tag string, target interface{}) error
- func (t *Table) One(key string, target interface{}) error
- func (t *Table) OneMap(key string) (map[string]string, error)
- func (t *Table) OneRaw(key string) ([]byte, error)
- func (t *Table) Save(key string, s string) ([]byte, error)
- func (t *Table) SaveBulk(s string) ([]byte, error)
Constants ¶
const ClassicDateFormat = "Mon Jan 2 2006 15:04:05 GMT-0700 (MST)"
ClassicDateFormat is used to parse a Salsa timestamp coming from the database.
const DateFormat = "2006-01-02"
DateFormat is used to format a time so that Engage will recognize it.
const EngageDateFormat = "2006-01-02T15:04:05.000Z"
EngageDateFormat is used to format a date for Engage.
const TimestampFormat = "2006-01-02T15:04:05"
TimestampFormat is used to format a time so that Engage will recognize it.
Variables ¶
This section is empty.
Functions ¶
func ClassicTime ¶
ClassicTime accepts a Classic timestamp and returns a time object.
func EngageDate ¶
EngageDate parses converts a string containing a MySQL date to another string containing an Engage date.
func EngageTimestamp ¶
EngageTimestamp parses converts a string containing a MySQL date to another string containing an Engage date and time.
Types ¶
type API ¶
type API struct { Client *http.Client Cookies []*http.Cookie Host string Verbose bool CredData CredData }
API hold the data that we need to do Salsa API calls. That includes the cookies from authentication.
func YAMLAuth ¶
YAMLAuth accepts campaign manager credentials (email, password, host) from a YAML file and authenticates.
func (*API) Authenticate ¶
Authenticate and save the cookies for later.
func (*API) EmailBlast ¶
EmailBlast is a shortcut for creating an EmailBlast Table object.
func (*API) Get ¶
Get reads the provided URL and returns the HTTP response, a body and an error. Get also adds the cookies that the API needs to prove authentication. Your application would probably be better off using One or Many.
func (*API) Groups ¶
Groups is a shorcut for creating a groups Table. Note that "groups" is the only table in the API that's plural.
func (*API) GroupsSupporters ¶
GroupsSupporters is a shortcut to join groups to supporters via the supporter_groups table. Use LeftJoin to get data for this object.
func (*API) SupporterDonation ¶
SupporterDonation is a shortcut for creating a Table that holds supporter and donation records. Use LeftJoin to get data for this object.
func (*API) SupporterGroups ¶
SupporterGroups is a shortcut for creating a supporter_group Table object.
func (*API) Unsubscribe ¶
Unsubscribe is a shortcut for creating an unsubscribe Table object.
type AuthStatus ¶
AuthStatus contains the information returned by Authentication.
type Chapter ¶
type Chapter struct { ChapterKey string `json:"chapter_KEY"` OrganizationKey string `json:"organization_KEY"` ParentKey string `json:"parent_KEY,omitempty"` ChapterTypeKey string `json:"chapter_type_KEY"` LastModified string `json:"Last_Modified"` DateCreated string `json:"Date_Created"` Name string `json:"Name"` READONLYShortName string `json:"READONLY_Short_Name,omitempty"` Description string `json:"Description,omitempty"` Official bool `json:"Official,omitempty"` Chartered bool `json:"Chartered,omitempty"` ChapterType string `json:"Chapter_Type,omitempty"` HomepageURL string `json:"Homepage_URL,omitempty"` Slogan string `json:"Slogan,omitempty"` Municipality string `json:"municipality,omitempty"` Region string `json:"region,omitempty"` PostalCode string `json:"postal_code,omitempty"` Country string `json:"Country,omitempty"` Status string `json:"Status,omitempty"` SiteID string `json:"siteID,omitempty"` Latitude string `json:"Latitude,omitempty"` Longitude string `json:"Longitude,omitempty"` Privacy string `json:"Privacy,omitempty"` BaseURL string `json:"Base_URL,omitempty"` SecureURL string `json:"Secure_URL,omitempty"` SyndicationOptions string `json:"Syndication_Options,omitempty"` }
Chapter describes a chapter for an organization. Chapters may be rooted at the "national" (organization) level, or may be rooted in other chapters.
type CredData ¶
CredData contains the info that we need to get into the API.
func Credentials ¶
Credentials retrieves the login credentials from a YAML login file.
type DeleteStatus ¶
DeleteStatus contins the info returned by deleting a record.
type Field ¶
type Field struct { Name string `json:"name,omitempty"` Nullable string `json:"nullable,omitempty"` Type string `json:"type,omitempty"` DefaultValue string `json:"defaultValue,omitempty"` Label string `json:"label,omitempty"` MaxLength string `json:"maxlength,omitempty"` IsCustom string `json:"isCustom,omitEmpty"` DisplayName string `json:"displayName,omitEmpty"` }
Field is used to describe table fields when calling Desfcribe.
type Organization ¶
type Organization struct { OrganizationKey string `json:"organization_KEY"` RootKey string `json:"root_Key,omitempty"` ParentKey string `json:"parent_Key,omitempty"` PartnerKey string `json:"partner_Key,omitempty"` LastModified string `json:"Last_Modified,omitempty"` DateCreated string `json:"Date_Created,omitempty"` PRIVATEDateCreated string `json:"PRIVATE_Date_Created,omitempty"` Name string `json:"Name"` Type string `json:"Type"` Status string `json:"Status"` READONLYShortName string `json:"READONLY_Short_Name,omitempty"` Description string `json:"Description,omitempty"` OrganizationHomepage string `json:"Organization_Homepage,omitempty"` NewsletterOrListserveName string `json:"Newsletter_or_Listserve_Name,omitempty"` CustomHeaderHTML string `json:"Custom_Header_HTML,omitempty"` PrintHeader string `json:"Print_Header,omitempty"` BaseURL string `json:"Base_URL"` SecureURL string `json:"Secure_URL"` Street string `json:"Street,omitempty"` Street2 string `json:"Street_2,omitempty"` City string `json:"City,omitempty"` State string `json:"State,omitempty"` Zip string `json:"Zip,omitempty"` PRIVATEZipPlus4 string `json:"PRIVATE_Zip_Plus_4,omitempty"` MailServer string `json:"mail_server,omitempty"` MailUser string `json:"mail_user,omitempty"` MailPass string `json:"mail_pass,omitempty"` MailStatus string `json:"Mail_Status,omitempty"` PromotionalCode string `json:"Promotional_Code,omitempty"` Interests string `json:"Interests,omitempty"` Note string `json:"Note,omitempty"` LinkTrackURL string `json:"Link_Track_URL,omitempty"` OpenTrackURL string `json:"Open_Track_URL,omitempty"` SalsifiedBOOLVALUE string `json:"salsified_BOOLVALUE,omitempty"` Salsified bool `json:"salsified,omitempty"` StatusLastModified string `json:"Status_Last_Modified,omitempty"` DateTrialStarted string `json:"Date_Trial_Started,omitempty"` ContractDate string `json:"Contract_Date,omitempty"` ToolsInContract string `json:"Tools_In_Contract,omitempty"` ClosedDate string `json:"Closed_Date,omitempty"` ClosedReason string `json:"Closed_Reason,omitempty"` DefaultEmailAddress string `json:"default_email_address,omitempty"` DefaultMerchantAccountKey string `json:"default_merchant_account_Key,omitempty"` MovedBOOLVALUE string `json:"moved_BOOLVALUE,omitempty"` Moved bool `json:"moved,omitempty"` BlastNotificationEmail string `json:"Blast_Notification_Email,omitempty"` Country string `json:"Country,omitempty"` ListSize string `json:"List_Size,omitempty"` Usages string `json:"Usages,omitempty"` HearAboutUs string `json:"hear_about_us,omitempty"` Tier string `json:"Tier,omitempty"` TaxStatus string `json:"Tax_Status,omitempty"` StaffContact string `json:"Staff_Contact,omitempty"` LanguageCode string `json:"language_code,omitempty"` DisableTokenAuthenticationBOOLVALUE string `json:"Disable_Token_Authentication_BOOLVALUE,omitempty"` DisableTokenAuthentication bool `json:"Disable_Token_Authentication,omitempty"` EnforcePackagePermissions string `json:"Enforce_Package_Permissions,omitempty"` RecommendedMailServer string `json:"recommended_mail_server,omitempty"` OverrideMailServerBOOLVALUE string `json:"override_mail_server_BOOLVALUE,omitempty"` OverrideMailServer bool `json:"override_mail_server,omitempty"` EmailBlastBrandingOptOutBOOLVALUE string `json:"Email_Blast_Branding_Opt_Out_BOOLVALUE,omitempty"` EmailBlastBrandingOptOut bool `json:"Email_Blast_Branding_Opt_Out,omitempty"` ExternalClientID string `json:"external_client_id,omitempty"` RecommendEmailBlastBrandingOptOutBOOLVALUE string `json:"Recommend_Email_Blast_Branding_Opt_Out_BOOLVALUE,omitempty"` RecommendEmailBlastBrandingOptOut bool `json:"Recommend_Email_Blast_Branding_Opt_Out,omitempty"` OrganizationID string `json:"organization_id,omitempty"` WebsiteForcedBrandingRequiredBOOLVALUE string `json:"Website_Forced_Branding_Required_BOOLVALUE,omitempty"` WebsiteForcedBrandingRequired bool `json:"Website_Forced_Branding_Required,omitempty"` AuthenticateEmailsBOOLVALUE string `json:"Authenticate_Emails_BOOLVALUE,omitempty"` AuthenticateEmails bool `json:"Authenticate_Emails,omitempty"` EnforceAutodedupeOnEmailSendBOOLVALUE string `json:"enforce_autodedupe_on_email_send_BOOLVALUE,omitempty"` EnforceAutodedupeOnEmailSend bool `json:"enforce_autodedupe_on_email_send,omitempty"` EnforceHTTPSBOOLVALUE string `json:"enforce_https_BOOLVALUE,omitempty"` EnforceHTTPS bool `json:"enforce_https,omitempty"` }
Organization describes a record for an Salsa Classic client. Be aware that the bulk of the non-identity and non-status fields have been deprecated.
type Results ¶
type Results struct { Object string `json:"object"` Key string `json:"key"` Result string `json:"result"` Messages []string `json:"messages"` }
Results is returned by API calls.
type SalsaTimestamp ¶
SalsaTimestamp provides a way to unmarshal Salsa's time into a time object. Salsa's time is "" when exported. The desired time should be ""/ Many thanks to OneOfOne https://stackoverflow.com/questions/25087960/json-unmarshal-time-that-isnt-in-rfc-3339-format
func (*SalsaTimestamp) IsSet ¶
func (ct *SalsaTimestamp) IsSet() bool
IsSet returns true if the provided timestamp is not empty.
func (*SalsaTimestamp) MarshalDate ¶
func (ct *SalsaTimestamp) MarshalDate() ([]byte, error)
MarshalJSON converts a Time into a Salsa timestamp string.
func (*SalsaTimestamp) MarshalJSON ¶
func (ct *SalsaTimestamp) MarshalJSON() ([]byte, error)
MarshalJSON converts a Time into a Salsa timestamp string.
func (*SalsaTimestamp) UnmarshalJSON ¶
func (ct *SalsaTimestamp) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON parses a byte slice in Salsa format and stores a time object.
type Table ¶
Table links an API to a Salsa database table.
func (*Table) Count ¶
Count returns the number of records in the table that match the criteria. You're responsible for providing valid criteria for the selected table. To just count records, pass an empty string in the criteria.
func (*Table) Delete ¶
Delete does a Salsa API /delete. The caller provides a key. We whack that record.
func (*Table) LeftJoin ¶
LeftJoin reads two or more tables from the database. The tables are joined on the primary key of the left table. For example, to find supporters and their donations would require a table join statement like 'supporter(supporter_KEY)donation'. The field supporter_KEY is the primary key in supporter and a foreign key in donation.
LeftJoin reads staring at offset. It will retrieve either count or 500 records, whichever is smaller. If crit is defined, then that is added to the URL as a condition to limit the number of supporters.
The target is a slice of schemas. The schemas contain the fields that you'd like to see. Be sure to use the form "table.fieldName" in the JSON extensions to assure that the data is retrieved correctly.
func (*Table) LeftJoinMap ¶
LeftJoinMap reads from Salsa and returns an array of maps. The results are unmarshalled using gjson. Each map containsa single record.
func (*Table) LeftJoinRaw ¶
LeftJoinRaw does a left join using Salsa's API and returns a buffer of bytes.
func (*Table) Many ¶
Many reads many records from a table. Reading starts at offset and retrieves count records. Salsa will never return more than 500 records, however. The target is a slice of records that match the table schema. Many automatically unmarshals from JSON into the target. An empty target indicates end of data.
func (*Table) ManyMap ¶
ManyMap returns an array of records. Each record is a map of field names and values. An empty array indicates end of data.
func (*Table) ManyMapTagged ¶
func (t *Table) ManyMapTagged(offset int32, count int, crit string, tag string) ([]map[string]string, error)
ManyMapTagged returns an array of records that have a common tag. Each record is a map of field names and values. An empty array indicates end of data.
func (*Table) ManyRaw ¶
ManyRaw reads many records from a table. Reading starts at offset and retrieves count records. Salsa will never return more than 500 records, however. The results are unmarshalled data in JSON format.
func (*Table) ManyRawTagged ¶
ManyRawTagged reads many records from a table. Records share a common tag. Reading starts at offset and retrieves count records. Salsa will never return more than 500 records, however.
func (*Table) ManyTagged ¶
func (t *Table) ManyTagged(offset int32, count int, crit string, tag string, target interface{}) error
ManyTagged reads many records from a table. Records share a common tag. Reading starts at offset and retrieves count records. Salsa will never return more than 500 records, however.
The target is a slice of records that match the table schema. Many automatically unmarshals from JSON into the target. An empty target indicates end of data.
func (*Table) One ¶
One retrieves a single record using the provided primary key. The target is the address of a record schema, which defines which fields will be returned. Note that there is not currently a way to retrieve all fields into a schema. Use ManyMap to do that.
func (*Table) OneMap ¶
OneMap retrieves a single record using the provided primary key. The returned record is a map of names and values. Everything is a string.
func (*Table) OneRaw ¶
OneRaw retrieves a single record using the provided primary key. Returns the buffer retrieved from the URL.
func (*Table) Save ¶
Save does a Salsa API /save. The caller provides a buffer of fields to changed in the form "fieldname=value".
The buffer can be inordinately long. Salsa may not process a truly long buffer. YMWV.
func (*Table) SaveBulk ¶
SaveBulk does a Salsa API /save. The caller provides the contents of the body for a POST. In general, the contents can be characterized as "&object=" followed by the table name, "&key=" followed by zero or the primary key and multiple instances of "&FieldName=Value" SaveBulk returns the body of the response and an error