Sha256: e2f21d200de706f352836079a79f4b0c96282155dae4acc3863c2c4ddcfdd345

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'active_support/deprecation'
require 'active_support/core_ext/module'
require 'active_support/core_ext/hash'
require 'active_support/inflector'
require 'rest-client'
require 'nokogiri'

# utils
require 'civicrm/client'
require 'civicrm/xml'
require 'civicrm/resource'
require 'civicrm/profiling'
require 'civicrm/version'

# actions
require 'civicrm/actions/list'
require 'civicrm/actions/create'
require 'civicrm/actions/update'
require 'civicrm/actions/destroy'
require 'civicrm/actions/find'

# exceptions
require 'civicrm/errors'

# resources
require 'civicrm/resources/base'

module CiviCrm
  Error = Class.new(Exception)

  include Profiling

  @@api_key = nil
  @@site_key = nil
  @@api_base = 'https://www.example.org/path/to/civi/codebase'
  @@api_version = 'v3'
  @@user_authenticated = false

  mattr_accessor :api_key, :api_base, :api_version, :site_key

  def self.api_url(path = '')
    base = "#{api_base}/civicrm/extern/rest.php?#{path}"
    base += "&api_key=#{@@api_key}" if @@api_key
    base += "&key=#{@@site_key}" if @@site_key
    base
  end

  def self.authenticate(name, password)
    auth = Client.request(:post, q: 'civicrm/login', name: name, pass: password)
    @@api_key = auth[0]['api_key']
  end

  def self.api_key=(key)
    @@api_key = key
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
civicrm-1.1.1 lib/civicrm.rb
civicrm-1.1.0 lib/civicrm.rb
civicrm-1.0.7 lib/civicrm.rb