Sha256: e6f0f22a0cddfa5382d8dc369298c9439e523212c8d1b2fdfa692681d638c18f

Contents?: true

Size: 760 Bytes

Versions: 21

Compression:

Stored size: 760 Bytes

Contents

class Zendesk2::Client::MarkMembershipDefault < Zendesk2::Client::Request
  request_method :put
  request_path { |r| "/users/#{r.user_id}/organization_memberships/#{r.identity}/make_default.json" }

  def identity
    params.fetch("membership").fetch("id")
  end

  def user_id
    params.fetch("membership").fetch("user_id").to_i
  end

  def mock
    if (membership = self.find!(:memberships, identity)) && (membership["user_id"] == user_id)
      # only one user can be default
      other_user_memberships = self.data[:memberships].values.select { |m| m["user_id"]== user_id }
      other_user_memberships.each { |i| i["default"] = false }
      membership["default"] = true

      mock_response(params)
    else
      error!(:not_found)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zendesk2-1.7.5 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.7.4 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.7.2 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.7.1 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.7.0 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.6.1 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.17 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.16 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.15 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.14 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.13 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.12 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.11 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.10 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.9 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.8 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.7 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.6 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.5 lib/zendesk2/client/requests/mark_membership_default.rb
zendesk2-1.5.4 lib/zendesk2/client/requests/mark_membership_default.rb