updox 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ec52e4b2310bf45c257d8c4092d3c65f2d9586e49ef18b9600943af750d8af5
4
- data.tar.gz: 26a29009d85aab28861408b7266910c752486e9e93771e6d01601a3a76b426a5
3
+ metadata.gz: d1a4c56774d2ae35862e3f78e7d30f846e6d46718f4ef6085e32046f9d88c9d0
4
+ data.tar.gz: 89cb3f917db60bc0b987c30493a8d43abb34f984ac183580703f0ddf0add6adc
5
5
  SHA512:
6
- metadata.gz: 0c539a3fc2bc50adafb03ec452e2c3a738fe476bbcd3bde154f8f6e16f861584770bfaceea9f2461ade369cbc6f617b95204840ba94ef6d29e340bfee7caaebe
7
- data.tar.gz: 8a6fd9fd5711d3e6ba8dc8d3d607ffee81ca51f1980572f3364f1761c9c02fd596f89ed61939137dd5ae4e2152201734a3d9d78089a462c4707892af30ed2518
6
+ metadata.gz: f29e44f7ee6cfc00923d8c09fb53a3005ab462460b8cc7ff3a6199f09d7aa75c3f3c4060bf7ddae8bcc1d9bbb1f69dcddd40eced124c93da58d6fedf032182fc
7
+ data.tar.gz: 127d6d020b096c7e87c3a0267fa740340c41a4025f097db4cbb9fb7c36be790f37737e893f3241bd9558f61f3a700cbb4166a59f8ad0914ec35437c257a0627a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.5.0] - 2020-02-13
8
+ ### Added
9
+ - Practice#find
10
+ - Practice#exists?
11
+ - Location#query
12
+ - Location#find
13
+ - Location#exists?
14
+ - User#find
15
+ - Locaiton find and exists? have `cache` option
16
+
17
+ ### Changed
18
+ - Any model class returned has `successful?`, `response_code` and `response_message`
19
+
7
20
  ## [0.4.0] - 2020-02-11
8
21
  ### Changed
9
22
  - Minor grammar fixes
@@ -25,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
25
38
  ### Added
26
39
  - Initial Release with ability to ping Updox api
27
40
 
41
+ [0.5.0]: https://github.com/WeInfuse/updox/compare/v0.4.0...v0.5.0
28
42
  [0.4.0]: https://github.com/WeInfuse/updox/compare/v0.3.0...v0.4.0
29
43
  [0.3.0]: https://github.com/WeInfuse/updox/compare/v0.2.0...v0.3.0
30
44
  [0.2.0]: https://github.com/WeInfuse/updox/compare/v0.1.0...v0.2.0
data/README.md CHANGED
@@ -47,6 +47,12 @@ practice.create
47
47
  practices = Updox::Models::Practice.query.practices
48
48
  ```
49
49
 
50
+ #### Find
51
+ ```ruby
52
+ practice = Updox::Models::Practice.find('0001')
53
+ ```
54
+
55
+
50
56
  ### Location
51
57
 
52
58
  #### Create
@@ -59,6 +65,37 @@ location.save(account_id: practice.account_id)
59
65
  Location.sync([l0, l1], account_id: practice.account_id)
60
66
  ```
61
67
 
68
+ #### Query
69
+ ```ruby
70
+ locations = Updox::Models::Location.query(account_id: '0001')
71
+ ```
72
+
73
+ #### Find
74
+ There is no `find` in the api, we are doing a ruby `find` on the query - so use the `cached_query` option if you are doing a bunch of lookups
75
+
76
+ ```ruby
77
+ location = Updox::Models::Location.find(27, account_id: '0001')
78
+
79
+ cached_query_results = Updox::Models::Location.query(account_id: '0001')
80
+
81
+ 10.times do |id|
82
+ Updox::Models::Location.find(id, account_id: '0001', cached_query: cached_query_results)
83
+ end
84
+ ```
85
+
86
+ #### Exists?
87
+ See note on #find method about caching
88
+
89
+ ```ruby
90
+ Updox::Models::Location.exists?(27, account_id: '0001')
91
+
92
+ cached_query_results = Updox::Models::Location.query(account_id: '0001')
93
+
94
+ 10.times do |id|
95
+ Updox::Models::Location.exists?(id, account_id: '0001', cached_query: cached_query_results)
96
+ end
97
+ ```
98
+
62
99
  ### Calendar
63
100
 
64
101
  #### Create
@@ -93,11 +130,13 @@ Appointment.sync([appt0, appt1, appt2], account_id: practice.account_id)
93
130
  ```
94
131
 
95
132
  ### Response
96
- By default we return `Updox::Models::Model.from_response`
133
+ By default we usually return `Updox::Models::Model.from_response`
97
134
 
98
- This class throws if throw an exception on bad responses with a parsed error.
135
+ This class throws if throw an exception on non 200 responses with a parsed error.
99
136
 
100
- If successful it adds helper methods and converts each to the respective class.
137
+ Updox usually returns a `200` with error information even on things like `Unauthorized`. So you may have to check the updox status via `successful?` method.
138
+
139
+ If HTTP 200 it adds helper methods and converts each to the respective class.
101
140
 
102
141
  The raw response is stored in the resulting model but you can get the raw response by setting config option to false
103
142
 
@@ -106,6 +145,11 @@ response = Updox::Models::Practice.query
106
145
  response.practices # Has the practices as Updox::Models::Practice model
107
146
  response.items # Same as practices, always exists on any model if alias is broken
108
147
  response.item # If there is no array, we populate this object
148
+
149
+ resposne.successful? # Indicates Updox successful indication
150
+ resposne.response_code? # Indicates Updox response code
151
+ resposne.response_message? # Indicates Updox response message
152
+
109
153
  response.response # Raw HTTParty response is here
110
154
  ```
111
155
 
@@ -8,8 +8,11 @@ module Updox
8
8
 
9
9
  format :json
10
10
 
11
- def request(endpoint: Updox::Models::Auth::PING_ENDPOINT, body: {}, headers: {}, auth: Updox::Models::Auth.new, required_auths: [])
11
+ def request(endpoint: Updox::Models::Auth::PING_ENDPOINT, body: {}, headers: {}, auth: Updox::Models::Auth.new, required_auths: [], account_id: nil, user_id: nil)
12
12
  if body.is_a?(Hash)
13
+ auth[:accountId] = account_id unless account_id.nil?
14
+ auth[:userId] = user_id unless user_id.nil?
15
+
13
16
  body = auth_data(auth, required_auths).merge(body)
14
17
  body = body.to_json
15
18
  end
@@ -2,21 +2,57 @@ module Updox
2
2
  module Models
3
3
  class Location < Model
4
4
  SYNC_ENDPOINT = '/LocationsSync'.freeze
5
+ LIST_ENDPOINT = '/PracticeLocationsRetrieve'.freeze
6
+
7
+ LIST_TYPE = 'locations'
8
+ LIST_NAME = LIST_TYPE
5
9
 
6
10
  property :id
7
11
  property :code
8
12
  property :name
13
+ property :address1
14
+ property :address2
15
+ property :city
16
+ property :state
17
+ property :zip
18
+ property :dayphone, from: :phone
19
+ property :evephone
20
+ property :faxphone, from: :fax
21
+ property :apptphone
22
+ property :emailAddress, from: :email
23
+ property :emailAddress, from: :email_address
9
24
  property :showInPortal, default: false, from: :show_in_portal
10
25
  property :active, default: true
11
26
 
27
+ # This is only on response
28
+ property :external_id, from: :externalId
29
+
12
30
  alias_method :show_in_portal, :showInPortal
31
+ alias_method :phone, :dayphone
32
+ alias_method :fax, :faxphone
33
+ alias_method :email, :emailAddress
34
+ alias_method :email_address, :emailAddress
13
35
 
14
36
  def save(account_id: )
15
37
  self.class.sync([self], account_id: account_id)
16
38
  end
17
39
 
40
+ def self.exists?(location_id, account_id: , cached_query: nil)
41
+ false == self.find(location_id, account_id: account_id, cached_query: cached_query).nil?
42
+ end
43
+
44
+ def self.find(location_id, account_id: , cached_query: nil)
45
+ obj = cached_query || self.query(account_id: account_id)
46
+
47
+ obj.locations.find {|location| location_id.to_s == location.external_id.to_s }
48
+ end
49
+
50
+ def self.query(account_id: , active_only: false)
51
+ from_response(UpdoxClient.connection.request(endpoint: LIST_ENDPOINT, body: { activeOnly: active_only }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT))
52
+ end
53
+
18
54
  def self.sync(locations, account_id: )
19
- from_response(UpdoxClient.connection.request(endpoint: SYNC_ENDPOINT, body: { locations: locations }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT), self)
55
+ from_response(UpdoxClient.connection.request(endpoint: SYNC_ENDPOINT, body: { locations: locations }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT))
20
56
  end
21
57
  end
22
58
  end
@@ -8,9 +8,23 @@ module Updox
8
8
 
9
9
  LIST_TYPE = 'undefined'
10
10
  LIST_NAME = 'models'
11
+ ITEM_TYPE = 'model'
11
12
 
12
13
  property :item, required: false
13
14
  property :items, required: false
15
+ property :updox_status, default: {}
16
+
17
+ def successful?
18
+ self[:updox_status].dig('successful')
19
+ end
20
+
21
+ def response_code
22
+ self[:updox_status].dig('responseCode')
23
+ end
24
+
25
+ def response_message
26
+ self[:updox_status].dig('responseMessage')
27
+ end
14
28
 
15
29
  def self.from_response(response, klazz = self)
16
30
  return response if false == Updox.configuration.parse_responses?
@@ -26,10 +40,15 @@ module Updox
26
40
  elsif data&.include?(klazz.const_get(:LIST_TYPE))
27
41
  model.items = data.dig(klazz.const_get(:LIST_TYPE)).map { |obj| klazz.new(obj) }
28
42
  model.define_singleton_method(klazz.const_get(:LIST_NAME)) { self.items }
43
+ elsif data&.include?(klazz.const_get(:ITEM_TYPE))
44
+ model.item = klazz.new(data.dig(klazz.const_get(:ITEM_TYPE)))
45
+ model.define_singleton_method(klazz.const_get(:ITEM_TYPE)) { self.item }
29
46
  else
30
47
  model.items = [data]
31
48
  model.item = data
32
49
  end
50
+
51
+ model.updox_status = data&.select {|k,v| ['successful', 'responseMessage', 'responseCode'].include?(k)} || {}
33
52
  else
34
53
  raise UpdoxException.from_response(response)
35
54
  end
@@ -8,10 +8,12 @@ module Updox
8
8
  property :firstName, from: :first_name
9
9
  property :middleName, from: :middle_name
10
10
  property :lastName, from: :last_name
11
+ property :emailAddress, from: :email
11
12
  property :emailAddress, from: :email_address
12
13
  property :homePhone, from: :home_phone
13
14
  property :workPhone, from: :work_phone
14
15
  property :mobileNumber, from: :mobile_number
16
+ property :mobileNumber, from: :mobile_phone
15
17
  property :active, default: true
16
18
 
17
19
  alias_method :email, :emailAddress
@@ -2,10 +2,12 @@ module Updox
2
2
  module Models
3
3
  class Practice < Model
4
4
  CREATE_ENDPOINT = '/PracticeCreate'.freeze
5
+ FIND_ENDPOINT = '/PracticeGet'.freeze
5
6
  QUERY_ENDPOINT = '/PracticeList'.freeze
6
7
 
7
8
  LIST_TYPE = 'practiceList'.freeze
8
9
  LIST_NAME = 'practices'
10
+ ITEM_TYPE = 'practice'
9
11
 
10
12
  property :name, required: true
11
13
  property :accountId, from: :account_id, with: ->(v) { v.to_s }
@@ -13,7 +15,7 @@ module Updox
13
15
  property :address2
14
16
  property :city
15
17
  property :state
16
- property :postal
18
+ property :postal, from: :zip
17
19
  property :phone
18
20
  property :fax
19
21
  property :websiteAddress, from: :website_address
@@ -31,13 +33,22 @@ module Updox
31
33
  property :active, default: true
32
34
 
33
35
  alias_method :account_id, :accountId
36
+ alias_method :zip, :postal
34
37
 
35
38
  def create
36
39
  UpdoxClient.connection.request(endpoint: CREATE_ENDPOINT, body: self.to_h, required_auths: Updox::Models::Auth::AUTH_APP)
37
40
  end
38
41
 
42
+ def self.exists?(account_id)
43
+ self.find(account_id).successful?
44
+ end
45
+
46
+ def self.find(account_id)
47
+ from_response(UpdoxClient.connection.request(endpoint: FIND_ENDPOINT, body: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_APP))
48
+ end
49
+
39
50
  def self.query
40
- from_response(UpdoxClient.connection.request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP), self)
51
+ from_response(UpdoxClient.connection.request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP))
41
52
  end
42
53
  end
43
54
  end
@@ -3,9 +3,11 @@ module Updox
3
3
  class User < Model
4
4
  SAVE_ENDPOINT = '/UserSave'.freeze
5
5
  QUERY_ENDPOINT = '/UserList'.freeze
6
+ FIND_ENDPOINT = '/UserGet'.freeze
6
7
 
7
8
  LIST_TYPE = 'userList'.freeze
8
9
  LIST_NAME = 'users'
10
+ ITEM_TYPE = 'user'
9
11
 
10
12
  property :userId, from: :user_id
11
13
  property :emrUserId, from: :emr_user_id
@@ -32,8 +34,12 @@ module Updox
32
34
  UpdoxClient.connection.request(endpoint: SAVE_ENDPOINT, body: self.to_h, required_auths: Updox::Models::Auth::AUTH_APP)
33
35
  end
34
36
 
37
+ def self.find(user_id, account_id: )
38
+ from_response(UpdoxClient.connection.request(endpoint: FIND_ENDPOINT, account_id: account_id, body: { userId: user_id}, required_auths: Updox::Models::Auth::AUTH_ACCT))
39
+ end
40
+
35
41
  def self.query
36
- from_response(UpdoxClient.connection.request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP), self)
42
+ from_response(UpdoxClient.connection.request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP))
37
43
  end
38
44
  end
39
45
  end
data/lib/updox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Updox
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: updox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Crockett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-11 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty