infusion_api 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ .idea/
5
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in infusion_api.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "infusion_api/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "infusion_api"
7
+ s.version = InfusionApi::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Matt Merrill"]
10
+ s.email = ["matt.the.dev@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Infusionsoft API Wrapper}
13
+ s.description = %q{Simple wrapper gem for the Infusionsoft XMLRPC API}
14
+
15
+ s.rubyforge_project = "infusion_api"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,66 @@
1
+ module InfusionApi
2
+ require "xmlrpc/client"
3
+
4
+ class Api
5
+
6
+ def initialize( app_name, key, single_instance = true)
7
+
8
+ if single_instance && @inst
9
+ return @inst
10
+ else
11
+ @key = key
12
+ @client = XMLRPC::Client.new3({'host' => app_name, 'path' => '/api/xmlrpc', 'port' => 443, 'use_ssl' => true })
13
+ end
14
+
15
+ if single_instance
16
+ @inst = self
17
+ end
18
+
19
+ self
20
+ end
21
+
22
+
23
+ #----------------------------------------------------
24
+ #---------------- Contact Service Calls -------------
25
+ #----------------------------------------------------
26
+
27
+ def contact_add(data)
28
+
29
+ c_id = send_call("ContactService.add", data)
30
+
31
+ if data.has_key?("Email")
32
+ # TODO: add email_optin
33
+ end
34
+
35
+ c_id
36
+ end
37
+
38
+ def contact_load(id, return_fields)
39
+ send_call("ContactService.load", return_fields)
40
+ end
41
+
42
+
43
+
44
+ #API class private methods
45
+
46
+ private
47
+
48
+ def send_call(method, *args)
49
+
50
+ begin
51
+
52
+ result = @client.call(method, @key, *args)
53
+
54
+ rescue XMLRPC::FaultException => e
55
+ puts "ERROR: Infusionsoft API || #{e.faultCode} - #{e.faultString}"
56
+ end
57
+
58
+ result
59
+
60
+ end
61
+
62
+
63
+ end
64
+
65
+
66
+ end
@@ -0,0 +1,3 @@
1
+ module InfusionApi
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: infusion_api
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
10
+ platform: ruby
11
+ authors:
12
+ - Matt Merrill
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-04 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Simple wrapper gem for the Infusionsoft XMLRPC API
22
+ email:
23
+ - matt.the.dev@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - Rakefile
34
+ - infusion_api.gemspec
35
+ - lib/infusion_api.rb
36
+ - lib/infusion_api/version.rb
37
+ has_rdoc: true
38
+ homepage: ""
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project: infusion_api
65
+ rubygems_version: 1.3.7
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Infusionsoft API Wrapper
69
+ test_files: []
70
+