crv_api_client 0.1.3

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.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +26 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/Guardfile +10 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +47 -0
  8. data/Rakefile +7 -0
  9. data/crv_api_client.gemspec +30 -0
  10. data/lib/crv_api_client/animals.rb +84 -0
  11. data/lib/crv_api_client/api/animals/animals.rb +1734 -0
  12. data/lib/crv_api_client/api/animals/animals_driver.rb +113 -0
  13. data/lib/crv_api_client/api/animals/animals_mapping_registry.rb +2082 -0
  14. data/lib/crv_api_client/api/animals/rs_animal_service_client.rb +122 -0
  15. data/lib/crv_api_client/api/animals.rb +9 -0
  16. data/lib/crv_api_client/api/reproduction/esb_rs_reproduction_service_client.rb +158 -0
  17. data/lib/crv_api_client/api/reproduction/reproduction.rb +8810 -0
  18. data/lib/crv_api_client/api/reproduction/reproduction_driver.rb +136 -0
  19. data/lib/crv_api_client/api/reproduction/reproduction_mapping_registry.rb +5244 -0
  20. data/lib/crv_api_client/api/reproduction.rb +9 -0
  21. data/lib/crv_api_client/api.rb +6 -0
  22. data/lib/crv_api_client/errors.rb +57 -0
  23. data/lib/crv_api_client/helpers/attributes.rb +34 -0
  24. data/lib/crv_api_client/helpers/crv.rb +89 -0
  25. data/lib/crv_api_client/helpers/endpoint.rb +46 -0
  26. data/lib/crv_api_client/helpers.rb +7 -0
  27. data/lib/crv_api_client/reproduction.rb +87 -0
  28. data/lib/crv_api_client/utils/configuration.rb +40 -0
  29. data/lib/crv_api_client/utils.rb +5 -0
  30. data/lib/crv_api_client/version.rb +3 -0
  31. data/lib/crv_api_client.rb +26 -0
  32. data/spec/lib/crv/animals_spec.rb +95 -0
  33. data/spec/lib/crv/api/animals/animals_driver_spec.rb +39 -0
  34. data/spec/lib/crv/api/reproduction/reproduction_driver_spec.rb +39 -0
  35. data/spec/lib/crv/helpers/attributes_spec.rb +52 -0
  36. data/spec/lib/crv/helpers/crv_spec.rb +146 -0
  37. data/spec/lib/crv/helpers/endpoint_spec.rb +54 -0
  38. data/spec/lib/crv/reproduction_spec.rb +137 -0
  39. data/spec/lib/crv_spec.rb +22 -0
  40. data/spec/spec_helper.rb +91 -0
  41. metadata +204 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0c563445f0c5b889da6747d2c4d7a68dd19d57ae52697fdade8e2c68a1583928
4
+ data.tar.gz: d5b42fcbd5152d2a292612b80ae85893f5758f467daebfffae4de3536b1b97ec
5
+ SHA512:
6
+ metadata.gz: 6121950db853da3fc38cf024383a4442ca6ff17eeaf153de0d6399ceb19e90f88afe9069d208ac6264b1c0b8a74bbdcd23fce523f272e848bf24f910817498ce
7
+ data.tar.gz: dab9942136865ea5f9fb0efea4bfaa4de2ec4925a34f0fb796ec293264421bc217d61a9d59f082d20881561eee94622e1d7c80a2a71a77f8586ceda93781cf92
data/.gitignore ADDED
@@ -0,0 +1,26 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .rvmrc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
24
+ .idea/
25
+ .DS_Store
26
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in crv_api_client.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ end
10
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Antek Drzewiecki
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.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # CRV API client
2
+
3
+ ## Installation
4
+
5
+ Add these lines to your application's Gemfile:
6
+
7
+ ```
8
+ source 'http://lm-gems:9292'
9
+ gem 'crv_api_client'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ ```
15
+ $ bundle
16
+ ```
17
+
18
+ Or install it yourself as:
19
+
20
+ ```
21
+ $ gem install crv_api_client
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Create a new client
27
+
28
+ ```ruby
29
+ crv_client = CrvApiClient::Animals.new
30
+ ```
31
+
32
+ Request a list of animals.
33
+
34
+ ```ruby
35
+ response = crv_client.list_animals(crv_id, country_code)
36
+ ```
37
+
38
+ ## Configuration
39
+ Configure the CRV client by passing it a block. For example:
40
+
41
+ ```ruby
42
+ success = CrvApiClient.configure do |config|
43
+ config.customer = {participant_code:"123",participant_code_type:"PAR", country_code:"NLD"}
44
+ config.username = 'thisisme'
45
+ config.password = 'verysecret'
46
+ end
47
+ ```
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'crv_api_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "crv_api_client"
8
+ spec.description = "CRV API client"
9
+ spec.homepage = "https://nedap.com"
10
+ spec.version = CrvApiClient::VERSION
11
+ spec.authors = ["Nedap"]
12
+ spec.email = ["development-lm@nedap.com"]
13
+ spec.summary = %q{A Wrapper for the CRV soap API.}
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.add_dependency "soap4r-ruby1.9", "~> 2.0.5"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", '~> 3.0.0'
25
+ spec.add_development_dependency 'guard', '~> 2.6.1'
26
+ spec.add_development_dependency 'guard-rspec', '~> 4.2.10'
27
+ spec.add_development_dependency 'webmock', '~> 1.18.0'
28
+ spec.add_development_dependency 'vcr', '~> 2.9.2'
29
+
30
+ end
@@ -0,0 +1,84 @@
1
+ module CrvApiClient
2
+ class Animals
3
+ extend ::CrvApiClient::Helpers::Attributes
4
+ include ::CrvApiClient::Helpers::Crv
5
+
6
+ attr_reader :endpoint_url
7
+ attr_reader :username
8
+ attr_reader :password
9
+ attr_reader_with_type :customer, ::CrvApiClient::Api::Animals::ParticipantId
10
+ attr_reader_with_type :provider, ::CrvApiClient::Api::Animals::ParticipantId
11
+
12
+ def initialize(endpoint_url= ::CrvApiClient.configuration.endpoint_animals,
13
+ username: ::CrvApiClient.configuration.username,
14
+ password: ::CrvApiClient.configuration.password,
15
+ customer: ::CrvApiClient.configuration.customer,
16
+ provider: ::CrvApiClient.configuration.provider)
17
+
18
+ @endpoint_url = endpoint_url
19
+ @username = username
20
+ @password = password
21
+ self.customer= ::CrvApiClient::Api::Animals::ParticipantId.new(customer[:participant_code], customer[:participant_code_type], customer[:country_code])
22
+ self.provider= ::CrvApiClient::Api::Animals::ParticipantId.new(provider[:participant_code], provider[:participant_code_type], provider[:country_code])
23
+ end
24
+
25
+ ##
26
+ # Fetches all animals from the crv_api_client database from a specific customer.
27
+ #
28
+ # notes::
29
+ # Ensure the CRV client is configured properly.
30
+ #
31
+ # parameters::
32
+ # crv_id the crv_api_client id of the farm.
33
+ # country_code: the country code of the farm.
34
+ # context_message_detail: context message, authentication.
35
+ # process_code: a process code if any
36
+ # options :: a Hash of options.
37
+ # {validate: false} when set to false, the response wont be validated for status codes.
38
+ #
39
+ # response:: a CrvApiClient::Api::Animals::ListHerdPedigreeResponse will be returned.
40
+ #
41
+ # usage::
42
+ # response = Class.list_animals(123,"NL",nil,nil)
43
+ def list_animals(crv_id, country_code, context_message_detail: nil,process_code: "", options: {})
44
+
45
+ keeper, context_message_detail = keeper_and_context_message_detail(crv_id,country_code)
46
+ context = context_message(keeper,
47
+ username: @username,
48
+ password: @password,
49
+ context_message_detail: context_message_detail,
50
+ customer: customer,
51
+ provider: provider,
52
+ process_code: process_code,
53
+ animal: nil,
54
+ organisation: nil)
55
+
56
+ requestType = CrvApiClient::Api::Animals::ListHerdPedigreeRequestType.new
57
+ requestType.keeper = keeper
58
+
59
+ request = CrvApiClient::Api::Animals::ListHerdPedigreeRequest.new
60
+ request.contextMessage = context
61
+ request.requestMessage = requestType
62
+
63
+ result = driver.listHerdPedigree(request)
64
+
65
+ perform_service_message_validation(result.serviceMessage) unless options[:validate] == false
66
+
67
+ result
68
+ end
69
+
70
+
71
+ private
72
+
73
+ def driver
74
+ @driver ||= begin
75
+ animal_soap_driver = CrvApiClient::Api::Animals::RsAnimalPortType.new(@endpoint_url)
76
+ animal_soap_driver.options['protocol.http.connect_timeout'] = CrvApiClient.configuration.http_connect_timeout || 220
77
+ animal_soap_driver.options['protocol.http.receive_timeout'] = CrvApiClient.configuration.http_receive_timeout || 220
78
+ animal_soap_driver.options['protocol.http.ssl_config.verify_mode'] = nil
79
+ animal_soap_driver.wiredump_file_base = CrvApiClient.configuration.log_file
80
+ animal_soap_driver
81
+ end
82
+ end
83
+ end
84
+ end