method_crm 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ spec/support/config.yml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in method_crm.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Torey Heinz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,59 @@
1
+ # MethodCrm
2
+
3
+ A ruby wrapper for the MethodCRM API
4
+
5
+ A complete list of service methods can be found here: [https://www.methodintegration.com/MethodAPI/service.asmx](https://www.methodintegration.com/MethodAPI/service.asmx). For this gem the V2 version of methods is assumed.
6
+
7
+ ## Usage
8
+
9
+ client = MethodClient.new('Company', 'username', 'P@SSw0rd')
10
+
11
+ client.table_list
12
+ => ["Account", "AccountAccountType", ... "VendorCreditLineItem", "VendorType"]
13
+
14
+ client.table_list(:detailed)
15
+ => [
16
+ [ 0] {
17
+ "TableName" => "Account",
18
+ "SupportsAdd" => "true",
19
+ "SupportsEdit" => "true"
20
+ },
21
+ [ 1] {
22
+ "TableName" => "AccountAccountType",
23
+ "SupportsAdd" => "false",
24
+ "SupportsEdit" => "false"
25
+ },
26
+ ...
27
+ [155] {
28
+ "TableName" => "VendorCreditLineItem",
29
+ "SupportsAdd" => "true",
30
+ "SupportsEdit" => "true"
31
+ },
32
+ [156] {
33
+ "TableName" => "VendorType",
34
+ "SupportsAdd" => "true",
35
+ "SupportsEdit" => "false"
36
+ }
37
+ ]
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ gem 'method_crm'
44
+
45
+ And then execute:
46
+
47
+ $ bundle
48
+
49
+ Or install it yourself as:
50
+
51
+ $ gem install method_crm
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create new Pull Request
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ task :default => :spec
@@ -0,0 +1,33 @@
1
+ require 'rest_client'
2
+ require 'multi_xml'
3
+ module MethodCrm
4
+ class Client
5
+
6
+ def initialize(company, username, password)
7
+ @auth = {strCompanyAccount: company, strLogin: username, strPassword: password, strSessionID: nil}
8
+ end
9
+
10
+ def table_list
11
+ parsed_response('TableList')
12
+ end
13
+
14
+ def field_list(table)
15
+ parsed_response('FieldList', {'strTable' => table})
16
+ end
17
+
18
+ def get_records(table, fields = :all_fields)
19
+ if fields == :all_fields
20
+ fields = field_list(table).map { |field| field['FieldName'] }.join(',')
21
+ end
22
+ data = @auth.merge({strTable: table, strFields: fields, strWhereClause: nil, strGroupByClause: nil, strHaving: nil, strOrderBy: nil})
23
+ parsed_response('Select_XML', data)
24
+ end
25
+
26
+ private
27
+ def parsed_response(opperation, data={})
28
+ result = RestClient.post("http://www.methodintegration.com/MethodAPI/service.asmx/MethodAPI#{opperation}V2", @auth.merge(data))
29
+ content = MultiXml.parse(result)['string']['__content__']
30
+ MultiXml.parse(content)['MethodAPI']['MethodIntegration']['Record']
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.name = "method_crm"
4
+ gem.version = '0.0.1'
5
+
6
+ gem.author = 'Torey Heinz'
7
+ gem.email = 'toreyheinz@gmail.com'
8
+ gem.description = %q{A ruby wrapper for the MethodCRM API}
9
+ gem.summary = gem.description
10
+ gem.homepage = 'https://github.com/toreyheinz/method_crm'
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.require_path = 'lib'
14
+
15
+ gem.add_dependency 'rest-client', '~> 1.6'
16
+ gem.add_dependency 'multi_xml'
17
+
18
+ gem.add_development_dependency 'rake', '~> 0.9'
19
+ gem.add_development_dependency 'rspec', '~> 2.11'
20
+ gem.test_files = gem.files.grep(/^spec/)
21
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe MethodCrm::Client do
4
+ let(:client) {MethodCrm::Client.new(CONFIG[:company], CONFIG[:user], CONFIG[:password])}
5
+
6
+ it '#table_list returns an array of table hashes' do
7
+ client.table_list.all? {|hash| hash.has_key?('TableName')}.should be
8
+ end
9
+
10
+ it '#field_list returns an array of field hashes' do
11
+ client.field_list('Invoice').all? {|hash| hash.has_key?('FieldName')}.should be
12
+ end
13
+
14
+ it '#get_records returns a table`s records' do
15
+ client.get_records('Account').all? {|hash| hash.has_key?('AccountNumber')}.should be
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ require 'method_crm'
2
+ CONFIG = YAML.load_file(File.expand_path('../support/config.yml', __FILE__))
3
+
4
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each{|f| require f }
@@ -0,0 +1,3 @@
1
+ :company: Company
2
+ :user: admin
3
+ :password: P@SSw0rd
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: method_crm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Torey Heinz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_xml
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.9'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.11'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.11'
78
+ description: A ruby wrapper for the MethodCRM API
79
+ email: toreyheinz@gmail.com
80
+ executables: []
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - .gitignore
85
+ - Gemfile
86
+ - LICENSE
87
+ - README.md
88
+ - Rakefile
89
+ - lib/method_crm.rb
90
+ - method_crm.gemspec
91
+ - spec/method_crm_spec.rb
92
+ - spec/spec_helper.rb
93
+ - spec/support/config.example.yml
94
+ homepage: https://github.com/toreyheinz/method_crm
95
+ licenses: []
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ segments:
107
+ - 0
108
+ hash: 2400250086319970818
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ segments:
116
+ - 0
117
+ hash: 2400250086319970818
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.24
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: A ruby wrapper for the MethodCRM API
124
+ test_files:
125
+ - spec/method_crm_spec.rb
126
+ - spec/spec_helper.rb
127
+ - spec/support/config.example.yml