Sha256: 6d3b45391dc7f42d5731f0e43faa010db2d145afc5483efb4d80c0559c99d242

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 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/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)

  @@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

4 entries across 4 versions & 1 rubygems

Version Path
civicrm-1.0.6 lib/civicrm.rb
civicrm-1.0.5 lib/civicrm.rb
civicrm-1.0.4 lib/civicrm.rb
civicrm-1.0.2 lib/civicrm.rb