ramco 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1ba4d5cfa71ff453203b64fe47e5f1e9f0605cab61d0ac030aeab022c69d1088
4
+ data.tar.gz: 11f3cb4d1d4a2530a3dfda0e136c74bd53d4521a676b6953314550965e494192
5
+ SHA512:
6
+ metadata.gz: 98269f7726e4f61ca5f09cf547686bcbc53673d6f25b0225d51d02c7a2e5f24fab5cff9c2d34641805ac6acd166048d9d85f1a8f3c98290a48f55231bfa14795
7
+ data.tar.gz: '0808430731bbbe0c6a64453be274d0f57c444770b6718a8c9a8d0978be818f3c32349e7aa076f66b53c47ff8aefdf1ad710aa1e1ad7f67fbfb48b818f9395446'
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ Gemfile.lock
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /spec/responses/
11
+ /spec/settings.yml
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.2
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kurt@connectspaceinc.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Kurt Kowitz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # Ramco Ruby
2
+
3
+ This is an unofficial ruby client for the [RAMCOAMS API](https://api.ramcoams.com/api/v2/ramco_api_v2_doc.pdf). The end goal is a complete, intuitive and simple ruby API for working with the RAMCOAMS API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ramco'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ramco
20
+
21
+ # Usage
22
+
23
+ Instantiate the client using a provided RAMCOAMS API key:
24
+
25
+ ramco = Ramco.api_key("api_key")
26
+
27
+ ## GetEntity
28
+
29
+ Fetch the attributes and/or relationships of one specific entity using guid.
30
+
31
+ ramco.get_entity({"entity" => "Contact", "guid" => "6868642f-0144-e811-9c17-00155d10120d", "attributes" => "ContactId,FirstName,LastName"})
32
+
33
+ * post params
34
+ * Entity = Type of entity being queried (ex: Contact)
35
+ * Guid = guid of entity to return
36
+ * Attributes = comma separated list of attributes to return
37
+
38
+ ## GetEntities
39
+
40
+ Fetch the attributes and/or relationships of multiple entities of one type using a user-defined filter.
41
+
42
+ ramco.get_entities({"entity" => "Contact", "attributes" => "ContactId,FirstName,LastName", "maxresults" => "5"})
43
+
44
+ * post params
45
+ * Entity = Name of entity being queried (ex: Contact)
46
+ * Filter (optional) = User-specified filter string
47
+ * Attributes = comma separated list of attributes to return
48
+ * StringDelimiter (optional) = User-specified delimiter used to wrap string values (default is #)
49
+ * MaxResults (optional) = Maximum number of entities to return
50
+
51
+ ## GetEntityMetadata
52
+
53
+ Fetch metadata on entity type Contact (includes entity description, attributes and relationships).
54
+
55
+ ramco.get_entity_metadata({"entity" => "Contact"})
56
+
57
+ ## GetEntityTypes
58
+
59
+ Fetch all entities in the system.
60
+
61
+ ramco.get_entity_types
62
+
63
+ ## GetOptionSet
64
+
65
+ Fetch the valid value/label pairs for the specified OptionSet (what Ramco calls a picklist)
66
+
67
+ ramco.get_option_set({"entity" => "Contact", "attribute" => "PreferredPhone"})
68
+
69
+ * post params
70
+ * Entity = Name of entity being queried (ex: Contact)
71
+ * Attribute= Name of the attribute being queried (ex: PreferredPhone)
72
+
73
+ ## ValidateUser
74
+
75
+ Returns the globally unique id of a contact that matches the provided cobalt_username and cobalt_password parameters. Returns a 422 error when there is no user with provided username/password combination.
76
+
77
+ ramco.validate_user({"cobalt_username" => "username", "cobalt_password" => "password"})
78
+
79
+ * Post params:
80
+ * cobalt_username = User’s username
81
+ * cobalt_password = User’s password
82
+
83
+ ## ClearCache
84
+
85
+ Clears the server-side metadata cache. If an entity or attribute has been added (or removed), then clearing the cache will permit the changes to be reflected immediately. The cache will normally expire every 24 hours.
86
+
87
+ ramco.clear_cache
88
+
89
+ # Testing
90
+
91
+ The test suite uses [VCR](https://github.com/myronmarston/vcr) to cache actual requests to the RAMCO API in a directory called responses in the spec directory.
92
+
93
+ In order for VCR to make and cache the actual calls to the RAMCO API you will need to copy spec/settings.yml.sample to spec/settings.yml and configure it with your RAMCO key or add RAMCO_KEY as an environment variable.
94
+
95
+ This file is ignored by git (see .gitignore) so you can commit any changes you make to the gem without having to worry about your key being released into the wild.
96
+
97
+ Now run the test suite:
98
+
99
+ bundle
100
+ bundle exec rake api
101
+
102
+ ## Contributing
103
+
104
+ Bug reports and pull requests are welcome on GitHub at https://github.com/message-blocks/ramco-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
105
+
106
+ If you'd like to hack on Ramco-ruby, start by forking the repo on GitHub:
107
+
108
+ https://github.com/message-blocks/ramco-ruby
109
+
110
+ The best way to get your changes merged back into core is as follows:
111
+
112
+ 1. Clone down your fork
113
+ 1. Create a thoughtfully named topic branch to contain your change
114
+ 1. Hack away
115
+ 1. Add tests and make sure everything still passes by running `bundle exec rake`
116
+ 1. If you are adding new functionality, document it in the README
117
+ 1. Do not change the version number, we will do that on our end
118
+ 1. If necessary, rebase your commits into logical chunks, without errors
119
+ 1. Push the branch up to GitHub
120
+ 1. Send a pull request for your branch
121
+
122
+ ## License
123
+
124
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
125
+
126
+ ## Code of Conduct
127
+
128
+ Everyone interacting in the Ramco Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ramco/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ desc "Run the specs"
5
+ RSpec::Core::RakeTask.new do |t|
6
+ #t.rspec_opts = %w(-fs --color)
7
+ end
8
+
9
+ task :default => :spec
10
+ task :test => :spec
11
+
12
+ desc "Run the api specs"
13
+ RSpec::Core::RakeTask.new do |t|
14
+ t.name = :api
15
+ t.pattern = "spec/ramco/api/*_spec.rb"
16
+ end
17
+
18
+ desc "Open an irb session with library"
19
+ task :console do
20
+ sh "irb -I lib -r ramco"
21
+ end
22
+
23
+ desc "clean out VCR responses"
24
+ task :clean do
25
+ sh "rm -rf spec/responses"
26
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ramco"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ class Ramco
2
+ module API
3
+ module ClearCache
4
+
5
+ # ClearCache
6
+ # Clears the server-side metadata cache. If an entity or attribute has been added (or removed),
7
+ # then clearing the cache will permit the changes to be reflected immediately.
8
+ # The cache will normally expire every 24 hours.
9
+ #
10
+ # Returns json
11
+ #
12
+ def clear_cache(params={})
13
+ params['operation'] = "ClearCache"
14
+ request(connection, params)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ class Ramco
2
+ module API
3
+ module Entities
4
+
5
+ # Get entities
6
+ # Fetch the attributes and/or relationships of multiple entities of one type using a user-defined filter.
7
+ #
8
+ # Entity = Name of entity being queried (ex: Contact)
9
+ # Filter (optional) = User-specified filter string
10
+ # Attributes = comma separated list of attributes to return
11
+ # StringDelimiter (optional) = User-specified delimiter used to wrap string values (default is #)
12
+ # MaxResults (optional) = Maximum number of entities to return
13
+ #
14
+ # {"entity" => "Contact", "attributes" => "ContactId,FirstName,LastName", "maxresults" => "5"}
15
+ #
16
+ # Returns json
17
+ #
18
+ def get_entities(params={})
19
+ params['operation'] = "GetEntities"
20
+ request(connection, params)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ class Ramco
2
+ module API
3
+ module Entity
4
+
5
+ # GetEntity
6
+ # Fetch the attributes and/or relationships of one specific entity using guid.
7
+ #
8
+ # Entity = Type of entity being queried (ex: Contact)
9
+ # Guid = guid of entity to return
10
+ # Attributes = comma separated list of attributes to return
11
+ #
12
+ # {"entity" => "Contact", "guid" => "6868642f-0144-e811-9c17-00155d10120d", "attributes" => "ContactId,FirstName,LastName"}
13
+ #
14
+ # Returns json
15
+ #
16
+ def get_entity(params={})
17
+ params['operation'] = "GetEntity"
18
+ request(connection, params)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ class Ramco
2
+ module API
3
+ module EntityMetadata
4
+
5
+ # GetEntityMetadata
6
+ # Fetch metadata on entity type, including entity description, attributes and relationships
7
+ # Entity = Name of entity being queried, for example: Contact
8
+ #
9
+ # {"entity" => "Contact"}
10
+ #
11
+ # Returns json
12
+ #
13
+ def get_entity_metadata(params={})
14
+ params['operation'] = "GetEntityMetadata"
15
+ request(connection, params)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ class Ramco
2
+ module API
3
+ module EntityTypes
4
+
5
+ # GetEntityTypes
6
+ # Returns a complete list of all entities in the system
7
+ #
8
+ # Returns json
9
+ #
10
+ def get_entity_types(params={})
11
+ params['operation'] = "GetEntityTypes"
12
+ request(connection, params)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ class Ramco
2
+ module API
3
+ module OptionSet
4
+
5
+ # GetOptionSet
6
+ # Fetch the valid value/label pairs for the specified OptionSet (what Ramco calls a picklist)
7
+ #
8
+ # Entity = Name of entity being queried (ex: Contact)
9
+ # Attribute = Name of the attribute being queried (ex: PreferredPhone)
10
+ #
11
+ # {"entity" => "Contact", "attribute" => "PreferredPhone"}
12
+ #
13
+ # Returns json
14
+ #
15
+ def get_option_set(params={})
16
+ params['operation'] = "GetOptionSet"
17
+ request(connection, params)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ class Ramco
2
+ module API
3
+ module ValidateUser
4
+
5
+ # ValidateUser
6
+ # Returns the globally unique id of a contact that matches the provided
7
+ # cobalt_username and cobalt_password parameters.
8
+ #
9
+ # Returns a 422 error when there is no user with provided username/password combination.
10
+ #
11
+ # cobalt_username = User's username
12
+ # cobalt_password = User's password
13
+ #
14
+ # {"cobalt_username" => "username", "cobalt_password" => "password"}
15
+ #
16
+ # Returns json
17
+ #
18
+ def validate_user(params={})
19
+ params['operation'] = "ValidateUser"
20
+ request(connection, params)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'multi_json'
4
+
5
+ class Ramco
6
+ class Connection < Faraday::Connection
7
+ attr_reader :hash, :api_key
8
+
9
+ # Instantiates connection, accepts an options hash
10
+ # for authenticated access
11
+ #
12
+ # Ramco expects
13
+ # :key => "API Key"
14
+
15
+ def initialize(hash={})
16
+ @hash = hash
17
+ @api_key = hash[:api_key] if hash.has_key? :api_key
18
+
19
+ super(hash[:api_url] || 'https://api.ramcoams.com/api/v2/') do |builder|
20
+ yield builder if block_given?
21
+ builder.use Faraday::Response::RaiseRamcoError
22
+ builder.use FaradayMiddleware::EncodeJson
23
+ builder.use FaradayMiddleware::ParseJson
24
+ builder.adapter :typhoeus
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,77 @@
1
+ require 'json/ext'
2
+ require 'multi_json'
3
+
4
+ class Ramco
5
+ # Custom error class for rescuing from all Ramco errors
6
+ class Error < StandardError
7
+ def initialize(response=nil)
8
+ @response = response
9
+ super(build_error_message)
10
+ end
11
+
12
+ def response_body
13
+ @response_body ||= if (body = @response[:body]) && !body.empty?
14
+ if false and body.is_a?(String)
15
+ MultiJson.load(body, :symbolize_keys => true)
16
+ else
17
+ body
18
+ end
19
+ else
20
+ nil
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def build_error_message
27
+ return nil if @response.nil?
28
+
29
+ message = if response_body
30
+ "#{response_body["ResponseCode"]}: #{response_body["ResponseText"]}"
31
+ else
32
+ ''
33
+ end
34
+
35
+ "#{message}"
36
+ end
37
+ end
38
+
39
+ # Raised when Ramco returns a 400 HTTP status code
40
+ class BadRequest < Error; end
41
+
42
+ # Raised when Ramco returns a 401 HTTP status code
43
+ class Unauthorized < Error; end
44
+
45
+ # Raised when Ramco returns a 404 HTTP status code
46
+ class NotFound < Error; end
47
+
48
+ # Raised when Ramco returns a 422 HTTP status code
49
+ class InvalidUser < Error; end
50
+
51
+ # Raised when Ramco returns a 500 HTTP status code
52
+ class InternalServerError < Error; end
53
+
54
+ # Raised when Ramco returns a 502 HTTP status code
55
+ class BadGateway < Error; end
56
+
57
+ # Raised when Ramco returns a 503 HTTP status code
58
+ class ServiceUnavailable < Error; end
59
+ end
60
+
61
+ module Faraday
62
+ class Response::RaiseRamcoError < Response::Middleware
63
+ ERROR_MAP = {
64
+ 400 => Ramco::BadRequest,
65
+ 401 => Ramco::Unauthorized,
66
+ 422 => Ramco::InvalidUser,
67
+ 500 => Ramco::InternalServerError,
68
+ 502 => Ramco::BadGateway,
69
+ 503 => Ramco::ServiceUnavailable
70
+ }
71
+
72
+ def on_complete(response)
73
+ key = response.body["ResponseCode"].to_i
74
+ raise ERROR_MAP[key].new(response) if ERROR_MAP.has_key? key
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,3 @@
1
+ class Ramco
2
+ VERSION = "0.1.1"
3
+ end
data/lib/ramco.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'ramco/version'
2
+ require 'ramco/connection'
3
+ require 'ramco/errors'
4
+ require 'ramco/api/clear_cache'
5
+ require 'ramco/api/entities'
6
+ require 'ramco/api/entity_metadata'
7
+ require 'ramco/api/entity_types'
8
+ require 'ramco/api/entity'
9
+ require 'ramco/api/option_set'
10
+ require 'ramco/api/validate_user'
11
+
12
+ class Ramco
13
+ attr_reader :connection
14
+
15
+ include Ramco::API::ClearCache
16
+ include Ramco::API::Entities
17
+ include Ramco::API::EntityMetadata
18
+ include Ramco::API::EntityTypes
19
+ include Ramco::API::Entity
20
+ include Ramco::API::OptionSet
21
+ include Ramco::API::ValidateUser
22
+
23
+
24
+ def initialize(options = {}, &block)
25
+ @options = options
26
+ @block = block if block
27
+ return @connection = Ramco::Connection.new(options, &block)
28
+ end
29
+
30
+ def self.api_key(api_key, api_url = nil)
31
+ options = {:api_key => api_key}
32
+ options[:api_url] = api_url if api_url
33
+ Ramco.new options
34
+ end
35
+
36
+ private
37
+
38
+ def request(connection, params)
39
+ connection.post do |req|
40
+ req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
41
+ req.body = params.merge({"key" => connection.api_key})
42
+ end.body["Data"]
43
+ end
44
+ end
data/ramco.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "ramco/version"
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "ramco"
6
+ spec.version = Ramco::VERSION
7
+ spec.required_ruby_version = ">= 2.4.6"
8
+ spec.authors = ["Kurt Kowitz"]
9
+ spec.email = ["kurt@connectspaceinc.com"]
10
+
11
+ spec.summary = %q{Access RAMCOAMS in ruby.}
12
+ spec.description = %q{A simple ruby API for accessing RAMCOAMS.}
13
+ spec.homepage = "https://github.com/message-blocks/ramco"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'faraday', '~> 0.9'
22
+ spec.add_dependency 'faraday_middleware', '~> 0.9'
23
+ spec.add_dependency 'multi_json', '~> 1.3'
24
+ spec.add_dependency 'typhoeus', '~> 0.7.0'
25
+
26
+ spec.add_development_dependency "bundler"
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec', '~>3.0'
29
+ spec.add_development_dependency 'json_pure'
30
+ spec.add_development_dependency 'webmock'
31
+ spec.add_development_dependency 'vcr'
32
+ spec.add_development_dependency 'pry-byebug'
33
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ramco::API::ClearCache do
4
+ subject { Ramco.api_key(RAMCO_KEY) }
5
+
6
+ describe "#clear_cache" do
7
+ it "should clear cache" do
8
+ VCR.use_cassette('clear cache') do
9
+ response = subject.clear_cache
10
+ expect(response).to be_nil
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ramco::API::Entities do
4
+ subject { Ramco.api_key(RAMCO_KEY) }
5
+
6
+ describe "#get_entities" do
7
+ it "should get entities" do
8
+ VCR.use_cassette('get entities') do
9
+ response = subject.get_entities({"entity" => "Contact", "attributes" => "ContactId,FirstName,LastName", "maxresults" => "2"})
10
+ expect(response.length).to eq(2)
11
+ expect(response[0]).to have_key "ContactId"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ramco::API::EntityMetadata do
4
+ subject { Ramco.api_key(RAMCO_KEY) }
5
+
6
+ describe "#get_entity_metadata" do
7
+ it "should get entity metadata" do
8
+ VCR.use_cassette('get entity metadata') do
9
+ response = subject.get_entity_metadata({"entity" => "Contact"})
10
+ expect(response).to be_instance_of(Hash)
11
+ expect(response).to have_key "Name"
12
+ expect(response["Name"]).to eq("Contact")
13
+ expect(response).to have_key "PrimaryIdAttribute"
14
+ expect(response["PrimaryIdAttribute"]).to eq("ContactId")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ramco::API::Entity do
4
+ subject { Ramco.api_key(RAMCO_KEY) }
5
+
6
+ describe "#get_entity" do
7
+ it "should get entity" do
8
+ VCR.use_cassette('get entity') do
9
+ response = subject.get_entity({"entity" => "Contact", "guid" => "6868642f-0144-e811-9c17-00155d10120d", "attributes" => "ContactId,FirstName,LastName"})
10
+ expect(response).to be_instance_of(Hash)
11
+ expect(response).to have_key "ContactId"
12
+ expect(response["ContactId"]).to eq("6868642f-0144-e811-9c17-00155d10120d")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ramco::API::EntityTypes do
4
+ subject { Ramco.api_key(RAMCO_KEY) }
5
+
6
+ describe "#get_entity_types" do
7
+ it "should get entity types" do
8
+ VCR.use_cassette('get entity types') do
9
+ response = subject.get_entity_types
10
+ expect(response).to be_instance_of(Hash)
11
+ expect(response).to have_key "contact"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ramco::Connection do
4
+ context "with an api_token" do
5
+ subject { Ramco::Connection.new({api_key: RAMCO_KEY}) }
6
+
7
+ describe "#initialize" do
8
+ it "should set an instance variable for api key" do
9
+ expect(subject.hash).to eq({api_key: RAMCO_KEY})
10
+ expect(subject.api_key).to eq(RAMCO_KEY)
11
+ end
12
+ end
13
+
14
+ describe "a valid authorized request" do
15
+ let(:response) do
16
+ VCR.use_cassette('authorized_request') do
17
+ subject.post do |req|
18
+ req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
19
+ req.body = {"key" => subject.api_key, "operation" => "GetEntity", "entity" => "Contact", "guid" => "6868642f-0144-e811-9c17-00155d10120d", "attributes" => "ContactId,FirstName,LastName"}
20
+ end
21
+ end
22
+ end
23
+
24
+ it "should return 200" do
25
+ expect(response.status).to eq(200)
26
+ end
27
+
28
+ it "should parse the json response" do
29
+ expect(response.body).to_not be_nil
30
+ end
31
+ end
32
+ end
33
+
34
+ context "without an api key" do
35
+ subject { Ramco::Connection.new }
36
+
37
+ describe "#initialize" do
38
+ it "should not set an instance variable for api key" do
39
+ expect(subject.hash).to eq({})
40
+ end
41
+ end
42
+
43
+ describe "any request" do
44
+ let(:response) do
45
+ VCR.use_cassette('unauthorized_request') do
46
+ subject.post
47
+ end
48
+ end
49
+ it "should raise error" do
50
+ expect {response}.to raise_error(Ramco::BadRequest)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ramco do
4
+ it "should have a VERSION constant" do
5
+ expect(Ramco.const_defined?('VERSION')).to be_truthy
6
+ end
7
+
8
+ describe "factory methods" do
9
+ context "with api key" do
10
+ it "should set up a connection" do
11
+ rc = Ramco.api_key "ABC123"
12
+ expect(rc.connection).to be_instance_of(Ramco::Connection)
13
+ expect(rc.connection.hash).to eq({api_key: "ABC123"})
14
+ end
15
+ end
16
+ end
17
+ describe "#initialize" do
18
+ context "with an api key" do
19
+ it "should set up a connection" do
20
+ rc = Ramco.new({api_key: "ABC123"})
21
+ expect(rc.connection).to be_instance_of(Ramco::Connection)
22
+ expect(rc.connection.hash).to eq({api_key: "ABC123"})
23
+ expect(rc.connection.api_key).to eq("ABC123")
24
+ end
25
+ end
26
+
27
+ context "without an access_token" do
28
+ it "should set up a connection" do
29
+ rc = Ramco.new
30
+ expect(rc.connection).to be_instance_of(Ramco::Connection)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ api_key: your_ramco_api_key
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+ require 'bundler'
3
+ Bundler.require :default, :test
4
+ require 'webmock/rspec'
5
+ require 'vcr'
6
+ require 'ramco'
7
+ require 'pry'
8
+
9
+ VCR.configure do |c|
10
+ c.cassette_library_dir = File.expand_path('../responses', __FILE__)
11
+ c.hook_into :webmock
12
+ c.default_cassette_options = {:record => :once}
13
+ c.allow_http_connections_when_no_cassette = true
14
+ end
15
+ if File.exists? File.expand_path("../settings.yml", __FILE__)
16
+ settings = YAML.load_file(File.expand_path('../settings.yml', __FILE__))
17
+ RAMCO_KEY = settings['api_key']
18
+ else
19
+ RAMCO_KEY = ENV["RAMCO_KEY"]
20
+ end
21
+ class Guid
22
+ def self.guid
23
+ UUIDTools::UUID.timestamp_create().to_s
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,237 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ramco
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Kurt Kowitz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: typhoeus
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: json_pure
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: vcr
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry-byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: A simple ruby API for accessing RAMCOAMS.
168
+ email:
169
+ - kurt@connectspaceinc.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".travis.yml"
177
+ - CODE_OF_CONDUCT.md
178
+ - Gemfile
179
+ - LICENSE.txt
180
+ - README.md
181
+ - Rakefile
182
+ - bin/console
183
+ - bin/setup
184
+ - lib/ramco.rb
185
+ - lib/ramco/api/clear_cache.rb
186
+ - lib/ramco/api/entities.rb
187
+ - lib/ramco/api/entity.rb
188
+ - lib/ramco/api/entity_metadata.rb
189
+ - lib/ramco/api/entity_types.rb
190
+ - lib/ramco/api/option_set.rb
191
+ - lib/ramco/api/validate_user.rb
192
+ - lib/ramco/connection.rb
193
+ - lib/ramco/errors.rb
194
+ - lib/ramco/version.rb
195
+ - ramco.gemspec
196
+ - spec/ramco/api/clear_cache_spec.rb
197
+ - spec/ramco/api/entities_spec.rb
198
+ - spec/ramco/api/entity_metadata_spec.rb
199
+ - spec/ramco/api/entity_spec.rb
200
+ - spec/ramco/api/entity_types_spec.rb
201
+ - spec/ramco/connection_spec.rb
202
+ - spec/ramco_spec.rb
203
+ - spec/settings.yml.sample
204
+ - spec/spec_helper.rb
205
+ homepage: https://github.com/message-blocks/ramco
206
+ licenses:
207
+ - MIT
208
+ metadata: {}
209
+ post_install_message:
210
+ rdoc_options: []
211
+ require_paths:
212
+ - lib
213
+ required_ruby_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: 2.4.6
218
+ required_rubygems_version: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ requirements: []
224
+ rubygems_version: 3.0.3
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: Access RAMCOAMS in ruby.
228
+ test_files:
229
+ - spec/ramco/api/clear_cache_spec.rb
230
+ - spec/ramco/api/entities_spec.rb
231
+ - spec/ramco/api/entity_metadata_spec.rb
232
+ - spec/ramco/api/entity_spec.rb
233
+ - spec/ramco/api/entity_types_spec.rb
234
+ - spec/ramco/connection_spec.rb
235
+ - spec/ramco_spec.rb
236
+ - spec/settings.yml.sample
237
+ - spec/spec_helper.rb