1 line
No EOL
3.4 KiB
Text
1 line
No EOL
3.4 KiB
Text
<!---
|
|
Copyright 2007 Brian Ghidinelli (http://www.ghidinelli.com/)
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you
|
|
may not use this file except in compliance with the License. You may
|
|
obtain a copy of the License at:
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
--->
|
|
<cfcomponent name="oauth" output="false" hint="Object for holding accesstokens and secrets for services like Dwolla which authorize users with OAuth 2.0">
|
|
<cfproperty name="accesstoken" type="string" default="" />
|
|
<cfproperty name="secret" type="string" default="" />
|
|
|
|
<!---
|
|
PROPERTIES
|
|
--->
|
|
<cfset variables.instance = structNew() />
|
|
<cfset variables.instance.accesstoken = "" />
|
|
<cfset variables.instance.secret = "" />
|
|
|
|
<!---
|
|
INITIALIZATION / CONFIGURATION
|
|
--->
|
|
<cffunction name="init" access="public" returntype="accesstoken" output="false">
|
|
<cfargument name="accesstoken" type="any" required="false" default="" />
|
|
<cfargument name="secret" type="any" required="false" default="" />
|
|
|
|
<cfset setAccessToken(arguments.accesstoken) />
|
|
<cfset setSecret(arguments.secret) />
|
|
|
|
<cfreturn this />
|
|
</cffunction>
|
|
|
|
<!--- convenience boolean wrapper around validate() --->
|
|
<cffunction name="getIsValid" access="public" returntype="boolean" output="false" hint="True/false the bank account is valid">
|
|
<cfreturn arrayLen(validate()) EQ 0 />
|
|
</cffunction>
|
|
|
|
<!--- if we pass this successfully, we should be able to send it to the gateway safely --->
|
|
<cffunction name="validate" access="public" returntype="any" output="false">
|
|
<cfset var errors = arrayNew(1) />
|
|
<cfset var thisError = structNew() />
|
|
|
|
<!--- vault/customer ID (is optional, at least with braintree) --->
|
|
<cfif (NOT len(trim(getAccessToken())))>
|
|
<cfset thisError.field = "accesstoken" />
|
|
<cfset thisError.type = "required" />
|
|
<cfset thisError.message = "AccessToken is required" />
|
|
<cfset arrayAppend(errors, duplicate(thisError)) />
|
|
</cfif>
|
|
|
|
<cfreturn errors />
|
|
</cffunction>
|
|
|
|
|
|
<!---
|
|
ACCESSORS
|
|
--->
|
|
<cffunction name="setAccessToken" access="public" returntype="any" output="false"><cfset variables.instance.accesstoken = arguments[1] /><cfreturn this /></cffunction>
|
|
<cffunction name="getAccessToken" access="public" returntype="any" output="false"><cfreturn variables.instance.accesstoken /></cffunction>
|
|
<cffunction name="setSecret" access="public" returntype="any" output="false"><cfset variables.instance.secret = arguments[1] /><cfreturn this /></cffunction>
|
|
<cffunction name="getSecret" access="public" returntype="any" output="false"><cfreturn variables.instance.secret /></cffunction>
|
|
|
|
<!---
|
|
DUMP
|
|
--->
|
|
<cffunction name="dump" access="public" output="true" return="void">
|
|
<cfargument name="abort" type="boolean" default="false" />
|
|
<cfdump var="#variables.instance#" />
|
|
<cfif arguments.abort>
|
|
<cfabort />
|
|
</cfif>
|
|
</cffunction>
|
|
|
|
<!--- Date: 7/6/2008 Usage: return a copy of the internal values --->
|
|
<cffunction name="getMemento" output="false" access="public" returntype="any" hint="return a copy of the internal values">
|
|
<cfreturn duplicate(variables.instance) />
|
|
</cffunction>
|
|
|
|
</cfcomponent>
|