Sha256: 164a02c095fd2e72e77788391cb6f0381b195002cbb77101464bb819299bee8e

Contents?: true

Size: 1.92 KB

Versions: 28

Compression:

Stored size: 1.92 KB

Contents

require_relative '../model'
module Spaceship
  class ConnectAPI
    class User
      include Spaceship::ConnectAPI::Model

      attr_accessor :username
      attr_accessor :first_name
      attr_accessor :last_name
      attr_accessor :email
      attr_accessor :preferred_currency_territory
      attr_accessor :agreed_to_terms
      attr_accessor :roles
      attr_accessor :all_apps_visible
      attr_accessor :provisioning_allowed
      attr_accessor :email_vetting_required
      attr_accessor :notifications

      attr_accessor :visible_apps

      attr_mapping({
        "username" => "username",
        "firstName" => "first_name",
        "lastName" => "last_name",
        "email" => "email",
        "preferredCurrencyTerritory" => "preferred_currency_territory",
        "agreedToTerms" => "agreed_to_terms",
        "roles" => "roles",
        "allAppsVisible" => "all_apps_visible",
        "provisioningAllowed" => "provisioning_allowed",
        "emailVettingRequired" => "email_vetting_required",
        "notifications" => "notifications",

        "visibleApps" => "visible_apps"
      })

      ESSENTIAL_INCLUDES = [
        "visibleApps"
      ].join(",")

      def self.type
        return "users"
      end

      #
      # API
      #

      def self.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, limit: nil, sort: nil)
        client ||= Spaceship::ConnectAPI
        resps = client.get_users(filter: filter, includes: includes).all_pages
        return resps.flat_map(&:to_models)
      end

      def self.find(client: nil, email: nil, includes: ESSENTIAL_INCLUDES)
        client ||= Spaceship::ConnectAPI
        return all(client: client, filter: { email: email }, includes: includes)
      end

      def get_visible_apps(client: nil, limit: nil)
        client ||= Spaceship::ConnectAPI
        resp = client.get_user_visible_apps(user_id: id, limit: limit)
        return resp.to_models
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
fastlane-2.205.2 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.205.1 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.205.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.204.3 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.204.2 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.204.1 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.204.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.203.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.202.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.201.2 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.201.1 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.201.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.201.0.rc3 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.201.0.rc2 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.201.0.rc1 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.200.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.199.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.198.1 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.198.0 spaceship/lib/spaceship/connect_api/models/user.rb
fastlane-2.197.0 spaceship/lib/spaceship/connect_api/models/user.rb