lib/zendesk2/user.rb in zendesk2-1.8.1 vs lib/zendesk2/user.rb in zendesk2-1.9.0
- old
+ new
@@ -68,29 +68,29 @@
def save!
data = if new_record?
requires :name, :email
- service.create_user("user" => self.attributes)
+ cistern.create_user("user" => self.attributes)
else
requires :identity
- service.update_user("user" => self.attributes)
+ cistern.update_user("user" => self.attributes)
end.body["user"]
merge_attributes(data)
end
def destroy!
requires :identity
- if self.email == service.username
+ if self.email == cistern.username
raise "don't nuke yourself"
end
merge_attributes(
- service.destroy_user("user" => {"id" => self.identity}).body["user"]
+ cistern.destroy_user("user" => {"id" => self.identity}).body["user"]
)
end
def destroyed?
!reload || !self.active
@@ -103,13 +103,13 @@
# @see http://www.zendesk.com/support/api/remote-authentication
def login_url(timestamp, options={})
requires :name, :email
return_to = options[:return_to]
- token = self.service.token || options[:token]
+ token = self.cistern.token || options[:token]
- uri = URI.parse(self.service.url)
+ uri = URI.parse(self.cistern.url)
uri.path = "/access/remote"
raise "timestamp cannot be nil" unless timestamp
hash_str = "#{self.name}#{self.email}#{token}#{timestamp}"
@@ -135,13 +135,13 @@
# Cargo-culted from: https://github.com/zendesk/zendesk_jwt_sso_examples/blob/master/ruby_on_rails_jwt.rb
def jwt_login_url(options = {})
requires :name, :email
return_to = options[:return_to]
- jwt_token = self.service.jwt_token || options[:jwt_token]
+ jwt_token = self.cistern.jwt_token || options[:jwt_token]
- uri = URI.parse(self.service.url)
+ uri = URI.parse(self.cistern.url)
uri.path = "/access/jwt"
iat = Time.now.to_i
jti = "#{iat}/#{rand(36**64).to_s(36)}"
payload = JWT.encode({
@@ -165,31 +165,31 @@
# @return [Zendesk2::Tickets] tickets this user requested
def tickets
requires :identity
- service.tickets(requester_id: self.identity)
+ cistern.tickets(requester_id: self.identity)
end
alias requested_tickets tickets
# @return [Zendesk2::Tickets] tickets this user is CC'd
def ccd_tickets
requires :identity
- service.tickets(collaborator_id: self.identity)
+ cistern.tickets(collaborator_id: self.identity)
end
# @return [Zendesk2::UserIdentities] the identities of this user
def identities
- self.service.user_identities("user_id" => self.identity)
+ self.cistern.user_identities("user_id" => self.identity)
end
# @return [Zendesk2::Memberships] the organization memberships of this user
def memberships
- self.service.memberships(user: self)
+ self.cistern.memberships(user: self)
end
# @return [Zendesk2::Organizations] the organizations of this user through memberships
def organizations
- self.service.organizations(user: self)
+ self.cistern.organizations(user: self)
end
end