updox 0.5.0 → 0.6.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: d1a4c56774d2ae35862e3f78e7d30f846e6d46718f4ef6085e32046f9d88c9d0
4
- data.tar.gz: 89cb3f917db60bc0b987c30493a8d43abb34f984ac183580703f0ddf0add6adc
3
+ metadata.gz: 012ec2142bd40cd1717538f15d9c20d93020c63526bd6ef6db06ede30596dd75
4
+ data.tar.gz: 676af6481645729aaf1c9ecdd187185c853203174ead58120375de8d4322a362
5
5
  SHA512:
6
- metadata.gz: f29e44f7ee6cfc00923d8c09fb53a3005ab462460b8cc7ff3a6199f09d7aa75c3f3c4060bf7ddae8bcc1d9bbb1f69dcddd40eced124c93da58d6fedf032182fc
7
- data.tar.gz: 127d6d020b096c7e87c3a0267fa740340c41a4025f097db4cbb9fb7c36be790f37737e893f3241bd9558f61f3a700cbb4166a59f8ad0914ec35437c257a0627a
6
+ metadata.gz: ce55c116e9a6f25022a2515194c16fc894f6cc60218971cbe22cded9d85f17184080b1056e22f9c65d9e95bb1ef79b3c241ef8216f37dc8e52de8a21a1f3d51e
7
+ data.tar.gz: 202765e4aba6a39adc1e99f7bbb67b7d5366d87b74c298bd3ed8f26d85bd3e251f75d38b33e02e6197f631e59109a896c977a08524818e21c7c81c7365e30a33
data/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ 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.6.0] - 2020-02-13
8
+ ### Added
9
+ - Calendar#query
10
+ - Calendar#find
11
+ - Calendar#exists?
12
+ - Patient#exists?
13
+ - Appointment#query
14
+ - Appointment#find
15
+ - Appointment#exists?
16
+ - Models now have `error_message` class that returns string with code and message
17
+
18
+ ### Changed
19
+ - All models now return and instance of `Model` for consistency
20
+
7
21
  ## [0.5.0] - 2020-02-13
8
22
  ### Added
9
23
  - Practice#find
@@ -38,6 +52,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
38
52
  ### Added
39
53
  - Initial Release with ability to ping Updox api
40
54
 
55
+ [0.6.0]: https://github.com/WeInfuse/updox/compare/v0.5.0...v0.6.0
41
56
  [0.5.0]: https://github.com/WeInfuse/updox/compare/v0.4.0...v0.5.0
42
57
  [0.4.0]: https://github.com/WeInfuse/updox/compare/v0.3.0...v0.4.0
43
58
  [0.3.0]: https://github.com/WeInfuse/updox/compare/v0.2.0...v0.3.0
data/README.md CHANGED
@@ -52,7 +52,6 @@ practices = Updox::Models::Practice.query.practices
52
52
  practice = Updox::Models::Practice.find('0001')
53
53
  ```
54
54
 
55
-
56
55
  ### Location
57
56
 
58
57
  #### Create
@@ -84,7 +83,7 @@ end
84
83
  ```
85
84
 
86
85
  #### Exists?
87
- See note on #find method about caching
86
+ See note on [Location#find](#location_find) method about caching
88
87
 
89
88
  ```ruby
90
89
  Updox::Models::Location.exists?(27, account_id: '0001')
@@ -97,6 +96,7 @@ end
97
96
  ```
98
97
 
99
98
  ### Calendar
99
+ See [Location](#location) for simliar #query, #find and #exists? methods
100
100
 
101
101
  #### Create
102
102
 
@@ -18,7 +18,7 @@ module Updox
18
18
  end
19
19
 
20
20
  def open(account_id: , user_id: )
21
- Model.from_response(UpdoxClient.connection.request(endpoint: OPEN_ENDPOINT, auth: {accountId: account_id, userId: user_id}, required_auths: Updox::Models::Auth::AUTH_FULL))
21
+ self.class.request(endpoint: OPEN_ENDPOINT, auth: {accountId: account_id, userId: user_id}, required_auths: Updox::Models::Auth::AUTH_FULL)
22
22
  end
23
23
  end
24
24
  end
@@ -2,6 +2,7 @@ module Updox
2
2
  module Models
3
3
  class Appointment < Model
4
4
  SYNC_ENDPOINT = '/AppointmentsSync'.freeze
5
+ LIST_ENDPOINT = '/AppointmentStatusesGetByIds'.freeze
5
6
 
6
7
  property :id, required: true
7
8
  property :updoxId, from: :updox_id
@@ -36,8 +37,22 @@ module Updox
36
37
  self.class.sync([self], account_id: account_id)
37
38
  end
38
39
 
40
+ def self.exists?(appointment_id, account_id: , cached_query: nil)
41
+ false == self.find(appointment_id, account_id: account_id, cached_query: cached_query).nil?
42
+ end
43
+
44
+ def self.find(appointment_id, account_id: , cached_query: nil)
45
+ obj = cached_query || self.query([appointment_id], account_id: account_id)
46
+
47
+ obj.item['appointmentStatuses'].find {|appointment| appointment_id.to_s == appointment[:externalAppointmentId].to_s }
48
+ end
49
+
50
+ def self.query(appointment_ids, account_id: , active_only: false)
51
+ request(endpoint: LIST_ENDPOINT, body: { apopintmentIds: appointment_ids }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
52
+ end
53
+
39
54
  def self.sync(appointments, account_id: )
40
- from_response(UpdoxClient.connection.request(endpoint: SYNC_ENDPOINT, body: { appointments: appointments.map(&:to_h) }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT), self)
55
+ request(endpoint: SYNC_ENDPOINT, body: { appointments: appointments.map(&:to_h) }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
41
56
  end
42
57
  end
43
58
  end
@@ -26,19 +26,19 @@ module Updox
26
26
  end
27
27
 
28
28
  def ping
29
- UpdoxClient.connection.request(endpoint: PING_ENDPOINT, auth: self)
29
+ Model.request(endpoint: PING_ENDPOINT, auth: self)
30
30
  end
31
31
 
32
32
  def ping_with_application_auth
33
- UpdoxClient.connection.request(endpoint: PING_APP_ENDPOINT, auth: self, required_auths: AUTH_APP)
33
+ Model.request(endpoint: PING_APP_ENDPOINT, auth: self, required_auths: AUTH_APP)
34
34
  end
35
35
 
36
36
  def ping_with_account_auth
37
- UpdoxClient.connection.request(endpoint: PING_ACCT_ENDPOINT, auth: self, required_auths: AUTH_ACCT)
37
+ Model.request(endpoint: PING_ACCT_ENDPOINT, auth: self, required_auths: AUTH_ACCT)
38
38
  end
39
39
 
40
40
  def ping_with_full_auth
41
- UpdoxClient.connection.request(endpoint: PING_FULL_ENDPOINT, auth: self, required_auths: AUTH_FULL)
41
+ Model.request(endpoint: PING_FULL_ENDPOINT, auth: self, required_auths: AUTH_FULL)
42
42
  end
43
43
  end
44
44
  end
@@ -2,21 +2,42 @@ module Updox
2
2
  module Models
3
3
  class Calendar < Model
4
4
  SYNC_ENDPOINT = '/CalendarsSync'.freeze
5
+ LIST_ENDPOINT = '/PracticeCalendarsRetrieve'.freeze
6
+
7
+ LIST_TYPE = 'calendars'
8
+ LIST_NAME = LIST_TYPE
5
9
 
6
10
  property :id, required: true
7
11
  property :title, required: true
8
- property :color, required: true, default: '#2DA2C8'
9
- property :textColor, required: true, from: :text_color, default: '#FFFFFF'
12
+ property :color, required: true, default: '#3AC'
13
+ property :textColor, required: true, from: :text_color, default: '#000'
10
14
  property :publicCalendar, default: false, from: :public_calendar
11
15
  property :active, default: true
12
16
  property :reminderTurnOff, default: false, from: :reminder_turn_off
13
17
 
18
+ # This is only on response
19
+ property :external_id, from: :externalId
20
+
14
21
  alias_method :text_color, :textColor
15
22
  alias_method :public_calendar, :publicCalendar
16
23
  alias_method :reminder_turn_off, :reminderTurnOff
17
24
 
18
25
  def create(account_id: )
19
- self.class.from_response(UpdoxClient.connection.request(endpoint: SYNC_ENDPOINT, body: self.to_h, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT))
26
+ self.class.request(endpoint: SYNC_ENDPOINT, body: self.to_h, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
27
+ end
28
+
29
+ def self.exists?(calendar_id, account_id: , cached_query: nil)
30
+ false == self.find(calendar_id, account_id: account_id, cached_query: cached_query).nil?
31
+ end
32
+
33
+ def self.find(calendar_id, account_id: , cached_query: nil)
34
+ obj = cached_query || self.query(account_id: account_id)
35
+
36
+ obj.calendars.find {|calendar| calendar_id.to_s == calendar.external_id.to_s }
37
+ end
38
+
39
+ def self.query(account_id: , active_only: false)
40
+ request(endpoint: LIST_ENDPOINT, body: { activeOnly: active_only }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
20
41
  end
21
42
  end
22
43
  end
@@ -48,11 +48,11 @@ module Updox
48
48
  end
49
49
 
50
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))
51
+ request(endpoint: LIST_ENDPOINT, body: { activeOnly: active_only }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
52
52
  end
53
53
 
54
54
  def self.sync(locations, account_id: )
55
- from_response(UpdoxClient.connection.request(endpoint: SYNC_ENDPOINT, body: { locations: locations }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT))
55
+ request(endpoint: SYNC_ENDPOINT, body: { locations: locations }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
56
56
  end
57
57
  end
58
58
  end
@@ -2,6 +2,8 @@ module Updox
2
2
  module Models
3
3
  DATETIME_FORMAT = '%Y-%m-%d %H:%M'.freeze
4
4
 
5
+ #BATCH_SIZE = 200
6
+
5
7
  class Model < Hashie::Trash
6
8
  include Hashie::Extensions::IgnoreUndeclared
7
9
  include Hashie::Extensions::IndifferentAccess
@@ -26,6 +28,14 @@ module Updox
26
28
  self[:updox_status].dig('responseMessage')
27
29
  end
28
30
 
31
+ def error_message
32
+ "#{response_code}: #{response_message}"
33
+ end
34
+
35
+ def self.request(**kwargs)
36
+ from_response(UpdoxClient.connection.request(kwargs))
37
+ end
38
+
29
39
  def self.from_response(response, klazz = self)
30
40
  return response if false == Updox.configuration.parse_responses?
31
41
 
@@ -31,8 +31,12 @@ module Updox
31
31
  self.class.sync([self], account_id: account_id)
32
32
  end
33
33
 
34
+ def self.exists?(patient_id, account_id: )
35
+ request(endpoint: MESSAGE_COUNT_ENDPOINT, body: { patientId: patient_id }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT).successful?
36
+ end
37
+
34
38
  def self.sync(patients, account_id: )
35
- from_response(UpdoxClient.connection.request(endpoint: SYNC_ENDPOINT, body: { patients: patients }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT), self)
39
+ request(endpoint: SYNC_ENDPOINT, body: { patients: patients }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
36
40
  end
37
41
  end
38
42
  end
@@ -36,7 +36,7 @@ module Updox
36
36
  alias_method :zip, :postal
37
37
 
38
38
  def create
39
- UpdoxClient.connection.request(endpoint: CREATE_ENDPOINT, body: self.to_h, required_auths: Updox::Models::Auth::AUTH_APP)
39
+ self.class.request(endpoint: CREATE_ENDPOINT, body: self.to_h, required_auths: Updox::Models::Auth::AUTH_APP)
40
40
  end
41
41
 
42
42
  def self.exists?(account_id)
@@ -44,11 +44,11 @@ module Updox
44
44
  end
45
45
 
46
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))
47
+ request(endpoint: FIND_ENDPOINT, body: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_APP)
48
48
  end
49
49
 
50
50
  def self.query
51
- from_response(UpdoxClient.connection.request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP))
51
+ request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP)
52
52
  end
53
53
  end
54
54
  end
@@ -31,15 +31,15 @@ module Updox
31
31
  alias_method :login_password, :loginPassword
32
32
 
33
33
  def create
34
- UpdoxClient.connection.request(endpoint: SAVE_ENDPOINT, body: self.to_h, required_auths: Updox::Models::Auth::AUTH_APP)
34
+ self.class.request(endpoint: SAVE_ENDPOINT, body: self.to_h, required_auths: Updox::Models::Auth::AUTH_APP)
35
35
  end
36
36
 
37
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))
38
+ request(endpoint: FIND_ENDPOINT, account_id: account_id, body: { userId: user_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
39
39
  end
40
40
 
41
41
  def self.query
42
- from_response(UpdoxClient.connection.request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP))
42
+ request(endpoint: QUERY_ENDPOINT, required_auths: Updox::Models::Auth::AUTH_APP)
43
43
  end
44
44
  end
45
45
  end
data/lib/updox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Updox
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: updox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Crockett