Sha256: cc5dcec4eb5bb31e05925198806764c6aa1de761418a98f586bf507c6ddb6ae6

Contents?: true

Size: 1.5 KB

Versions: 8

Compression:

Stored size: 1.5 KB

Contents

module ActsAsIcontact
  # The nested Client Folder resource from iContact.  Currently only supports retrieval -- and is 
  # highly targeted toward the _first_ client folder, since that seems to be the dominant use case.
  class ClientFolder < Resource
    # Derives from the Account resource.
    def self.base
      ActsAsIcontact.account
    end
    
    def self.resource_name
      'clientfolder'
    end
    
    def self.collection_name
      'clientfolders'
    end
    
    def self.uri_component
      'c'
    end
    
    def self.base
      ActsAsIcontact.account
    end
  end
  
  # The clientFolderId retrieved from iContact.  Can also be set manually for performance 
  # optimization, but remembers it so that it won't be pulled more than once anyway.
  def self.clientfolder_id
    @clientfolder_id ||= ClientFolder.first.clientFolderId.to_i
  end
  
  # Manually sets the clientFolderId used in subsequent calls.  Setting this in your 
  # initializer will save at least one unnecessary request to the iContact server.
  def self.clientfolder_id=(val)
    @clientfolder_id = val
  end
  
  # RestClient subresource scoped to the specific account ID.  Most other iContact calls will derive
  # from this one.
  def self.clientfolder
    @clientfolder ||= account["c/#{clientfolder_id}"]
  end
  
  # Clears the account resource from memory.  Called by reset_connection! since the only likely reason
  # to do this is connecting as a different user.
  def self.reset_clientfolder!
    @clientfolder = nil
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
SFEley-acts_as_icontact-0.3.2 lib/acts_as_icontact/resources/client.rb
SFEley-acts_as_icontact-0.4.0 lib/acts_as_icontact/resources/client.rb
SFEley-acts_as_icontact-0.4.2 lib/acts_as_icontact/resources/client.rb
SFEley-acts_as_icontact-0.4.3 lib/acts_as_icontact/resources/client.rb
acts_as_icontact-0.4.3 lib/acts_as_icontact/resources/client.rb
acts_as_icontact-0.4.2 lib/acts_as_icontact/resources/client.rb
acts_as_icontact-0.4.0 lib/acts_as_icontact/resources/client.rb
acts_as_icontact-0.3.2 lib/acts_as_icontact/resources/client.rb