Sha256: e7decbbcb786e4cc76867a90b6bc68ef9b32649a3a7ee3ae9e0d993272b844d7

Contents?: true

Size: 1 KB

Versions: 17

Compression:

Stored size: 1 KB

Contents

class Zendesk2::Client
  class Real
    def mark_user_identity_primary(params={})
      id      = params.delete("id")
      user_id = params.delete("user_id")
      path    = "/users/#{user_id}/identities/#{id}/make_primary.json"

      request(
        :method => :put,
        :path   => path,
      )
    end
  end
  class Mock
    def mark_user_identity_primary(params={})
      id      = params.delete("id")
      user_id = params.delete("user_id")
      path    = "/users/#{user_id}/identities/#{id}/make_primary.json"

      user_identity = self.find!(:identities, id)

      if user_identity && user_identity["user_id"] == user_id
        # only one user can be primary
        other_user_identities = self.data[:identities].values.select{|i| i["user_id"] == user_id}
        other_user_identities.map{|i| i["primary"] = false}
        user_identity["primary"] = true

        response(
          :method => :put,
          :path   => path
        )
      else
        error!(:not_found)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
zendesk2-1.2.7 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.2.6 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.2.5 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.2.4 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.2.3 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.2.2 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.2.1 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.2.0 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.1.3 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.1.2 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-1.0.0 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-0.5.4 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-0.5.3 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-0.5.2 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-0.5.1 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-0.5.0 lib/zendesk2/client/requests/mark_user_identity_primary.rb
zendesk2-0.4.5 lib/zendesk2/client/requests/mark_user_identity_primary.rb