daisybill_api 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +6 -6
  3. data/lib/daisybill_api.rb +5 -5
  4. data/lib/daisybill_api/configuration.rb +3 -3
  5. data/lib/daisybill_api/data.rb +2 -2
  6. data/lib/daisybill_api/data/client.rb +18 -12
  7. data/lib/daisybill_api/data/url.rb +2 -2
  8. data/lib/daisybill_api/ext.rb +5 -5
  9. data/lib/daisybill_api/ext/associations.rb +1 -0
  10. data/lib/daisybill_api/ext/attributes.rb +2 -2
  11. data/lib/daisybill_api/ext/attributes/type_castings.rb +10 -4
  12. data/lib/daisybill_api/ext/crud.rb +12 -11
  13. data/lib/daisybill_api/ext/crud/create.rb +2 -2
  14. data/lib/daisybill_api/ext/crud/update.rb +1 -1
  15. data/lib/daisybill_api/ext/crud/write_off.rb +11 -0
  16. data/lib/daisybill_api/ext/links.rb +3 -3
  17. data/lib/daisybill_api/ext/links/link.rb +2 -2
  18. data/lib/daisybill_api/models.rb +31 -26
  19. data/lib/daisybill_api/models/attachment.rb +3 -2
  20. data/lib/daisybill_api/models/base.rb +1 -1
  21. data/lib/daisybill_api/models/bill.rb +23 -10
  22. data/lib/daisybill_api/models/bill_mailing_address.rb +16 -0
  23. data/lib/daisybill_api/models/bill_payment.rb +6 -5
  24. data/lib/daisybill_api/models/bill_submission.rb +2 -2
  25. data/lib/daisybill_api/models/billing_provider.rb +10 -10
  26. data/lib/daisybill_api/models/claim_adjustment_reason.rb +11 -0
  27. data/lib/daisybill_api/models/claims_administrator.rb +2 -1
  28. data/lib/daisybill_api/models/contact.rb +19 -11
  29. data/lib/daisybill_api/models/error_report.rb +30 -0
  30. data/lib/daisybill_api/models/injury.rb +1 -0
  31. data/lib/daisybill_api/models/paper_eor.rb +6 -3
  32. data/lib/daisybill_api/models/patient.rb +4 -3
  33. data/lib/daisybill_api/models/payer.rb +3 -1
  34. data/lib/daisybill_api/models/pharmacy_bill.rb +20 -8
  35. data/lib/daisybill_api/models/place_of_service.rb +4 -3
  36. data/lib/daisybill_api/models/prescribing_provider.rb +2 -2
  37. data/lib/daisybill_api/models/referring_provider.rb +2 -2
  38. data/lib/daisybill_api/models/remittance.rb +3 -3
  39. data/lib/daisybill_api/models/rendering_provider.rb +2 -2
  40. data/lib/daisybill_api/models/request_for_second_review.rb +3 -3
  41. data/lib/daisybill_api/models/service_line_item_payment.rb +14 -0
  42. data/lib/daisybill_api/models/task.rb +26 -0
  43. data/lib/daisybill_api/models/user.rb +16 -0
  44. data/lib/daisybill_api/version.rb +1 -1
  45. data/spec/daisybill_api/configuration_spec.rb +3 -3
  46. data/spec/daisybill_api/data/client_spec.rb +44 -38
  47. data/spec/daisybill_api/data/rest_client/payload_spec.rb +6 -6
  48. data/spec/daisybill_api/data/url_spec.rb +6 -6
  49. data/spec/daisybill_api/ext/attributes/attribute_spec.rb +32 -32
  50. data/spec/daisybill_api/ext/attributes/type_castings_spec.rb +22 -18
  51. data/spec/daisybill_api/ext/links/link_spec.rb +15 -15
  52. data/spec/daisybill_api/ext/pageable_collection_spec.rb +1 -1
  53. data/spec/daisybill_api/models/address_spec.rb +1 -1
  54. data/spec/daisybill_api/models/attachment_spec.rb +3 -3
  55. data/spec/daisybill_api/models/bill_mailing_address_spec.rb +6 -0
  56. data/spec/daisybill_api/models/bill_payment_spec.rb +5 -3
  57. data/spec/daisybill_api/models/bill_spec.rb +6 -4
  58. data/spec/daisybill_api/models/bill_submission_spec.rb +2 -2
  59. data/spec/daisybill_api/models/billing_provider_spec.rb +2 -2
  60. data/spec/daisybill_api/models/claim_number_verification_spec.rb +1 -1
  61. data/spec/daisybill_api/models/claims_administrator_spec.rb +3 -2
  62. data/spec/daisybill_api/models/contact_spec.rb +29 -3
  63. data/spec/daisybill_api/models/disputed_service_spec.rb +1 -1
  64. data/spec/daisybill_api/models/employer_spec.rb +1 -1
  65. data/spec/daisybill_api/models/error_report_spec.rb +10 -0
  66. data/spec/daisybill_api/models/injury_spec.rb +2 -1
  67. data/spec/daisybill_api/models/paper_eor_spec.rb +4 -3
  68. data/spec/daisybill_api/models/patient_spec.rb +4 -4
  69. data/spec/daisybill_api/models/payer_spec.rb +3 -2
  70. data/spec/daisybill_api/models/{pharamcy_bill_spec.rb → pharmacy_bill_spec.rb} +7 -6
  71. data/spec/daisybill_api/models/place_of_service_spec.rb +5 -5
  72. data/spec/daisybill_api/models/prescribing_provider_spec.rb +2 -2
  73. data/spec/daisybill_api/models/referring_provider_spec.rb +2 -2
  74. data/spec/daisybill_api/models/remittance_spec.rb +2 -2
  75. data/spec/daisybill_api/models/rendering_provider_spec.rb +2 -2
  76. data/spec/daisybill_api/models/request_for_second_review_spec.rb +2 -2
  77. data/spec/daisybill_api/models/service_line_item_payment_spec.rb +6 -0
  78. data/spec/daisybill_api/models/service_line_item_spec.rb +1 -1
  79. data/spec/daisybill_api/models/task_spec.rb +19 -0
  80. data/spec/daisybill_api/models/user_spec.rb +14 -0
  81. data/spec/daisybill_api_spec.rb +10 -10
  82. metadata +21 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5e394aeb38a629cb30d3ac94ab4109406d42b09
4
- data.tar.gz: de0f33281e3ba2b4e951fe09717fc06de6d6a8a1
3
+ metadata.gz: 1f4e06ac630954fbf2b73acf8cbcdb70701a4023
4
+ data.tar.gz: 5c2279c1252d5b4c10a12ed8cf9bc540824f12c2
5
5
  SHA512:
6
- metadata.gz: d69f93ad1dd13209af33dc82b37d4cf08295f5e7f2a77b0bef204254de2110d60efb05fdbbc05902c5ec5dcf3ebc2c11f11a093606abb23939ea0511afafae8c
7
- data.tar.gz: 44d0d2cc4449be3e6b6ba58f5336ea388e972d68fa61beba88939def8354b2eeb57084842a4b2cf00355ad35520308b8a21d6c83ab45a766aff59f27b060fecc
6
+ metadata.gz: cc8a3e51e32e99b04b0c711ad18f3322733d8b6ac6ebcf7161a02de71e6a93ccba160eefcec399477d064a8976e483c99eef5d30c0f809efccda5ea2e85e9d33
7
+ data.tar.gz: e72d81a145c9e7b296b32b1f59516f55fa8df339b132c6e442572d1ff0fec73eac8daa585999d358ffb68865d865f0e681c9c6afb40432ad43ee7efd4299cf27
data/Rakefile CHANGED
@@ -1,19 +1,19 @@
1
1
  begin
2
- require 'bundler/setup'
2
+ require "bundler/setup"
3
3
  rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
5
  end
6
6
 
7
7
  require "yard"
8
8
 
9
9
  Bundler::GemHelper.install_tasks
10
10
 
11
- require 'rake/testtask'
11
+ require "rake/testtask"
12
12
 
13
13
  Rake::TestTask.new(:test) do |t|
14
- t.libs << 'lib'
15
- t.libs << 'test'
16
- t.pattern = 'test/**/*_test.rb'
14
+ t.libs << "lib"
15
+ t.libs << "test"
16
+ t.pattern = "test/**/*_test.rb"
17
17
  t.verbose = false
18
18
  end
19
19
 
data/lib/daisybill_api.rb CHANGED
@@ -1,11 +1,11 @@
1
- require 'daisybill_api/data'
2
- require 'daisybill_api/configuration'
3
- require 'daisybill_api/ext'
4
- require 'daisybill_api/models'
1
+ require "daisybill_api/data"
2
+ require "daisybill_api/configuration"
3
+ require "daisybill_api/ext"
4
+ require "daisybill_api/models"
5
5
 
6
6
  module DaisybillApi
7
7
  # @private
8
- ROOT = File.expand_path('../..', __FILE__)
8
+ ROOT = File.expand_path("../..", __FILE__)
9
9
 
10
10
  class << self
11
11
  attr_writer :configuration
@@ -1,4 +1,4 @@
1
- require 'logger'
1
+ require "logger"
2
2
 
3
3
  module DaisybillApi
4
4
  class Configuration
@@ -7,7 +7,7 @@ module DaisybillApi
7
7
  #
8
8
  # DaisybillApi.configuration.api_token # => "987654321zyxwvu"
9
9
  # DaisybillApi.configuration.api_token = "123456789abcdef" # => "123456789abcdef"
10
- # DaisybillApi.configuration.api_token # => "123456789abcdef"'
10
+ # DaisybillApi.configuration.api_token # => "123456789abcdef"
11
11
  #
12
12
  # @return [String]
13
13
  attr_accessor :api_token
@@ -35,7 +35,7 @@ module DaisybillApi
35
35
 
36
36
  def initialize
37
37
  @port = 443
38
- @host = 'go.daisybill.com'
38
+ @host = "go.daisybill.com"
39
39
  end
40
40
 
41
41
  # @private
@@ -1,5 +1,5 @@
1
- require 'daisybill_api/data/url'
2
- require 'daisybill_api/data/client'
1
+ require "daisybill_api/data/url"
2
+ require "daisybill_api/data/client"
3
3
 
4
4
  module DaisybillApi
5
5
  module Data
@@ -1,5 +1,5 @@
1
- require 'rest-client'
2
- require 'daisybill_api/data/rest_client/payload'
1
+ require "rest-client"
2
+ require "daisybill_api/data/rest_client/payload"
3
3
 
4
4
  module DaisybillApi
5
5
  # @private
@@ -9,12 +9,14 @@ module DaisybillApi
9
9
  class InternalServerError < BasicError; end
10
10
  class UnauthorizedError < BasicError; end
11
11
  class InvalidParams < BasicError; end
12
+ class MethodNotAllowed < BasicError; end
12
13
 
13
14
  def self.build(method, path, params = {})
14
15
  client = new method, path, params
15
- raise InternalServerError.new(client.response['error']) if client.error?
16
- raise UnauthorizedError.new(client.response['error']) if client.unauthorized?
17
- raise InvalidParams.new(client.response['error']) if client.forbidden?
16
+ raise InternalServerError.new(client.response["error"]) if client.error?
17
+ raise UnauthorizedError.new(client.response["error"]) if client.unauthorized?
18
+ raise InvalidParams.new(client.response["error"]) if client.forbidden?
19
+ raise MethodNotAllowed.new(client.response["error"]) if client.method_not_allowed?
18
20
  client
19
21
  end
20
22
 
@@ -28,7 +30,7 @@ module DaisybillApi
28
30
  method: method,
29
31
  url: url,
30
32
  payload: params,
31
- headers: { 'Content-Type' => 'application/json' }
33
+ headers: { "Content-Type" => "application/json" }
32
34
  }
33
35
  RestClient::Request.execute(data) { |response, request, status|
34
36
  @headers = response.headers
@@ -45,27 +47,31 @@ module DaisybillApi
45
47
  end
46
48
 
47
49
  def success?
48
- status == '200' || status == '201'
50
+ status == "200" || status == "201"
49
51
  end
50
52
 
51
53
  def bad_request?
52
- status == '400'
54
+ status == "400"
53
55
  end
54
56
 
55
57
  def unauthorized?
56
- status == '401'
58
+ status == "401"
57
59
  end
58
60
 
59
61
  def not_found?
60
- status == '404'
62
+ status == "404"
61
63
  end
62
64
 
63
65
  def forbidden?
64
- status == '403'
66
+ status == "403"
67
+ end
68
+
69
+ def method_not_allowed?
70
+ status == "405"
65
71
  end
66
72
 
67
73
  def error?
68
- status == '500'
74
+ status == "500"
69
75
  end
70
76
  end
71
77
  end
@@ -1,9 +1,9 @@
1
- require 'uri/http'
1
+ require "uri/http"
2
2
 
3
3
  module DaisybillApi
4
4
  module Data
5
5
  module Url
6
- DEFAULT_PATH = '/api/v1'
6
+ DEFAULT_PATH = "/api/v1"
7
7
 
8
8
  class << self
9
9
  def build(path, params = {})
@@ -1,8 +1,8 @@
1
- require 'daisybill_api/ext/attributes'
2
- require 'daisybill_api/ext/links'
3
- require 'daisybill_api/ext/crud'
4
- require 'daisybill_api/ext/associations'
5
- require 'daisybill_api/ext/pageable_collection'
1
+ require "daisybill_api/ext/attributes"
2
+ require "daisybill_api/ext/links"
3
+ require "daisybill_api/ext/crud"
4
+ require "daisybill_api/ext/associations"
5
+ require "daisybill_api/ext/pageable_collection"
6
6
 
7
7
  module DaisybillApi
8
8
  module Ext
@@ -16,6 +16,7 @@ module DaisybillApi
16
16
  define_method name do |params = {}|
17
17
  params.merge!(:"#{self.class.singular_key}_id" => self.id)
18
18
  params.merge!(path: "#{show_path}/#{name}") if options[:set_path]
19
+ params.merge!(path: clazz.constantize.index_path(id)) if options[:set_path] && options[:use_path_prefix]
19
20
  params.merge!(collection_key: options[:collection_key]) if options[:collection_key]
20
21
  clazz.constantize.all(params)
21
22
  end
@@ -1,5 +1,5 @@
1
- require 'daisybill_api/ext/attributes/type_castings'
2
- require 'daisybill_api/ext/attributes/attribute'
1
+ require "daisybill_api/ext/attributes/type_castings"
2
+ require "daisybill_api/ext/attributes/attribute"
3
3
 
4
4
  module DaisybillApi
5
5
  module Ext
@@ -1,4 +1,4 @@
1
- require 'open-uri'
1
+ require "open-uri"
2
2
 
3
3
  module DaisybillApi
4
4
  module Ext
@@ -24,8 +24,10 @@ module DaisybillApi
24
24
  to_attachment(value)
25
25
  when :float
26
26
  to_float(value)
27
+ when :hash
28
+ to_hash(value)
27
29
  else
28
- raise 'Unknown Type'
30
+ raise "Unknown Type"
29
31
  end
30
32
  end
31
33
 
@@ -59,18 +61,22 @@ module DaisybillApi
59
61
 
60
62
  def to_class(attributes, type)
61
63
  return attributes if attributes.is_a? type
62
- type.new attributes rescue nil
64
+ type.new(attributes) rescue nil
63
65
  end
64
66
 
65
67
  def to_array(values, type)
66
68
  return [] if values.nil?
67
- values.map { |value| convert_to value, type }
69
+ values.map { |value| convert_to(value, type) }
68
70
  end
69
71
 
70
72
  def to_attachment(value)
71
73
  return open(value) if value.is_a? String
72
74
  value if value.is_a?(StringIO) || value.kind_of?(IO)
73
75
  end
76
+
77
+ def to_hash(value)
78
+ value.to_h rescue nil
79
+ end
74
80
  end
75
81
  end
76
82
  end
@@ -1,9 +1,10 @@
1
- require 'daisybill_api/ext/crud/index'
2
- require 'daisybill_api/ext/crud/create'
3
- require 'daisybill_api/ext/crud/show'
4
- require 'daisybill_api/ext/crud/update'
5
- require 'daisybill_api/ext/crud/destroy'
6
- require 'daisybill_api/ext/crud/search'
1
+ require "daisybill_api/ext/crud/index"
2
+ require "daisybill_api/ext/crud/create"
3
+ require "daisybill_api/ext/crud/show"
4
+ require "daisybill_api/ext/crud/update"
5
+ require "daisybill_api/ext/crud/destroy"
6
+ require "daisybill_api/ext/crud/search"
7
+ require "daisybill_api/ext/crud/write_off"
7
8
 
8
9
  module DaisybillApi
9
10
  module Ext
@@ -12,7 +13,7 @@ module DaisybillApi
12
13
  module ClassMethods
13
14
  def rest_actions(*actions)
14
15
  actions.each { |action|
15
- name = action.capitalize
16
+ name = action.to_s.classify
16
17
  extend "DaisybillApi::Ext::CRUD::#{name}::ClassMethods".constantize
17
18
  include "DaisybillApi::Ext::CRUD::#{name}::InstanceMethods".constantize
18
19
  }
@@ -75,7 +76,7 @@ module DaisybillApi
75
76
 
76
77
  private
77
78
 
78
- PREFIX_LENGTH = 'daisybill_api_models_'.length
79
+ PREFIX_LENGTH = "daisybill_api_models_".length
79
80
 
80
81
  def demodulize(name)
81
82
  name[PREFIX_LENGTH..name.length]
@@ -104,7 +105,7 @@ module DaisybillApi
104
105
 
105
106
  def index_path
106
107
  params = self.class.path_prefix? ? [self.send(self.class.prefix_property)] : []
107
- self.class.index_path *params
108
+ self.class.index_path(*params)
108
109
  end
109
110
 
110
111
  def show_path
@@ -129,11 +130,11 @@ module DaisybillApi
129
130
  def process_response(client)
130
131
  if client.success?
131
132
  response = client.response.clone
132
- self.links = response.delete 'links'
133
+ self.links = response.delete "links"
133
134
  self.attributes = response
134
135
  true
135
136
  elsif client.bad_request?
136
- self.external_errors = client.response['errors']
137
+ self.external_errors = client.response["errors"]
137
138
  self.valid?
138
139
  else
139
140
  false
@@ -33,7 +33,7 @@ module DaisybillApi
33
33
  #
34
34
  # bill = DaisybillApi::Models::Bill.new(
35
35
  # injury_id: 345,
36
- # date_of_service: '2015-01-01',
36
+ # date_of_service: "2015-01-01",
37
37
  # rendering_provider_id: rp.id,
38
38
  # place_of_service_id: pos.id,
39
39
  # diagnosis_codes: ["72700"],
@@ -91,7 +91,7 @@ module DaisybillApi
91
91
  def save
92
92
  return create if new_record?
93
93
  return update if respond_to? :update
94
- message = '#save method is not supported for saved record'
94
+ message = "#save method is not supported for saved record"
95
95
  DaisybillApi.logger.error message
96
96
  raise NotImplementedError.new message
97
97
  end
@@ -21,7 +21,7 @@ module DaisybillApi
21
21
  def save
22
22
  return update unless new_record?
23
23
  return create if respond_to? :create
24
- message = '#save method is not supported for new record'
24
+ message = "#save method is not supported for new record"
25
25
  DaisybillApi.logger.error message
26
26
  raise NotImplementedError.new message
27
27
  end
@@ -0,0 +1,11 @@
1
+ module DaisybillApi
2
+ module Ext
3
+ module CRUD
4
+ module WriteOff
5
+ # @private
6
+ module InstanceMethods; end
7
+ module ClassMethods; end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- require 'daisybill_api/ext/links/link'
1
+ require "daisybill_api/ext/links/link"
2
2
 
3
3
  module DaisybillApi
4
4
  module Ext
@@ -19,7 +19,7 @@ module DaisybillApi
19
19
 
20
20
  module InstanceMethods
21
21
  def initialize(attributes)
22
- lnks = attributes.delete 'links'
22
+ lnks = attributes.delete "links"
23
23
  super(attributes)
24
24
  class_links.each { |link| links[link.name] = link.clone }
25
25
  self.links = lnks
@@ -27,7 +27,7 @@ module DaisybillApi
27
27
 
28
28
  def links=(values)
29
29
  return if values.nil?
30
- values.each { |link| write_link link['rel'], link['href'] }
30
+ values.each { |link| write_link link["rel"], link["href"] }
31
31
  end
32
32
 
33
33
  private
@@ -14,7 +14,7 @@ module DaisybillApi
14
14
  def value
15
15
  return unless href
16
16
  default_path = DaisybillApi::Data::Url::DEFAULT_PATH
17
- c = DaisybillApi::Data::Client.build(:get, href.gsub(default_path, ''))
17
+ c = DaisybillApi::Data::Client.build(:get, href.gsub(default_path, ""))
18
18
  klass.constantize.new(c.response) if c.success?
19
19
  end
20
20
 
@@ -27,7 +27,7 @@ module DaisybillApi
27
27
  end
28
28
 
29
29
  def foreign_id
30
- href.split('/').last
30
+ href.split("/").last
31
31
  end
32
32
  end
33
33
  end
@@ -1,30 +1,35 @@
1
- require 'daisybill_api/models/address'
2
- require 'daisybill_api/models/contact'
3
- require 'daisybill_api/models/base'
4
- require 'daisybill_api/models/claims_administrator'
5
- require 'daisybill_api/models/payer'
6
- require 'daisybill_api/models/bill_submission'
7
- require 'daisybill_api/models/billing_provider'
8
- require 'daisybill_api/models/employer'
9
- require 'daisybill_api/models/injury'
10
- require 'daisybill_api/models/patient'
11
- require 'daisybill_api/models/place_of_service'
12
- require 'daisybill_api/models/prescribing_provider'
13
- require 'daisybill_api/models/referring_provider'
14
- require 'daisybill_api/models/rendering_provider'
15
- require 'daisybill_api/models/attachment'
16
- require 'daisybill_api/models/service_line_item'
17
- require 'daisybill_api/models/bill'
18
- require 'daisybill_api/models/pharmacy_bill'
19
- require 'daisybill_api/models/bill_payment'
20
- require 'daisybill_api/models/claim_number_verification'
21
- require 'daisybill_api/models/remittance'
22
- require 'daisybill_api/models/paper_eor'
23
- require 'daisybill_api/models/disputed_service'
24
- require 'daisybill_api/models/request_for_second_review'
1
+ require "daisybill_api/models/address"
2
+ require "daisybill_api/models/base"
3
+ require "daisybill_api/models/bill_mailing_address"
4
+ require "daisybill_api/models/contact"
5
+ require "daisybill_api/models/claims_administrator"
6
+ require "daisybill_api/models/payer"
7
+ require "daisybill_api/models/bill_submission"
8
+ require "daisybill_api/models/billing_provider"
9
+ require "daisybill_api/models/employer"
10
+ require "daisybill_api/models/injury"
11
+ require "daisybill_api/models/patient"
12
+ require "daisybill_api/models/place_of_service"
13
+ require "daisybill_api/models/prescribing_provider"
14
+ require "daisybill_api/models/referring_provider"
15
+ require "daisybill_api/models/rendering_provider"
16
+ require "daisybill_api/models/attachment"
17
+ require "daisybill_api/models/service_line_item"
18
+ require "daisybill_api/models/bill"
19
+ require "daisybill_api/models/pharmacy_bill"
20
+ require "daisybill_api/models/claim_adjustment_reason"
21
+ require "daisybill_api/models/service_line_item_payment"
22
+ require "daisybill_api/models/bill_payment"
23
+ require "daisybill_api/models/claim_number_verification"
24
+ require "daisybill_api/models/remittance"
25
+ require "daisybill_api/models/paper_eor"
26
+ require "daisybill_api/models/disputed_service"
27
+ require "daisybill_api/models/request_for_second_review"
28
+ require "daisybill_api/models/error_report"
29
+ require "daisybill_api/models/user"
30
+ require "daisybill_api/models/task"
25
31
 
26
32
  module DaisybillApi
27
33
  # @private
28
- module Models
29
- end
34
+ module Models; end
30
35
  end