lib/lifen/user.rb in lifen-1.6.8 vs lib/lifen/user.rb in lifen-2.0.0

- old
+ new

@@ -3,11 +3,11 @@ include Virtus.model(finalize: false) attribute :token, "Lifen::Token" attribute :status, "Lifen::Status" attribute :settings, "Lifen::Settings" - attribute :channels, ["Lifen::Communication::Channel"] + attribute :channels, ["Lifen::Channel"] attribute :uuid, String attribute :email, String attribute :last_name, String attribute :first_name, String @@ -126,15 +126,15 @@ user_json[:uuid] = user_json["id"] user = new(user_json) Array(user_json["telecom"]).each do |telecom_json| - user.channels << Lifen::Communication::Channel.from_json(telecom_json, "telecom") + user.channels << Lifen::Channel.from_json(telecom_json, "telecom") end Array(user_json["address"]).each do |address_json| - user.channels << Lifen::Communication::Channel.from_json(address_json, "address") + user.channels << Lifen::Channel.from_json(address_json, "address") end user end @@ -150,14 +150,22 @@ filtered_params[params[:type]] = address json = application_client.post("fhir/Practitioner/#{uuid}/$add-address", filtered_params) - channel = Communication::Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: "#{Array(params[:lines]).join(", ")}, #{params[:postal_code]} #{params[:city]}") + channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: "#{Array(params[:lines]).join(", ")}, #{params[:postal_code]} #{params[:city]}") self.channels << channel channel + end + + def self.from_json(json) + reference = json["reference"] + + uuid = reference.gsub("Practitioner/", "") + + new(uuid: uuid) end private def application_client \ No newline at end of file