Sha256: 0b775b17c7196e695c7d485f768643093d40b84e7d1338cb6dcc46a30bdc34e8

Contents?: true

Size: 1.9 KB

Versions: 314

Compression:

Stored size: 1.9 KB

Contents

module Spaceship
  module Tunes
    class Member < TunesBase
      attr_accessor :email_address
      attr_accessor :firstname
      attr_accessor :lastname
      attr_accessor :username
      attr_accessor :not_accepted_invitation
      attr_accessor :user_id

      attr_mapping(
        'emailAddress.value' => :email_address,
        'firstName.value' => :firstname,
        'lastName.value' => :lastname,
        'userName' => :username,
        'dsId' => :user_id
      )

      ROLES = {
        admin: 'admin',
        app_manager: 'appmanager',
        sales: 'sales',
        developer: 'developer',
        marketing: 'marketing',
        reports: 'reports'
      }

      def roles
        parsed_roles = []
        raw_data["roles"].each do |role|
          parsed_roles << role["value"]["name"]
        end
        return parsed_roles
      end

      def admin?
        roles.include?(ROLES[:admin])
      end

      def app_manager?
        roles.include?(ROLES[:app_manager])
      end

      def preferred_currency
        currency_base = raw_data["preferredCurrency"]["value"]
        return {
          name:    currency_base["name"],
          code:    currency_base["currencyCode"],
          country: currency_base["countryName"],
          country_code: currency_base["countryCode"]
        }
      end

      def selected_apps
        parsed_apps = []
        raw_data["userSoftwares"]["value"]["grantedSoftwareAdamIds"].each do |app_id|
          parsed_apps << Application.find(app_id)
        end
        return parsed_apps
      end

      def not_accepted_invitation
        return true if raw_data["activationExpiry"]
        return false
      end

      def has_all_apps
        selected_apps.length == 0
      end

      def delete!
        client.delete_member!(self.user_id, self.email_address)
      end

      def resend_invitation
        client.reinvite_member(self.email_address)
      end
    end
  end
end

Version data entries

314 entries across 314 versions & 1 rubygems

Version Path
fastlane-2.63.0.beta.20171021010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171020010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171019010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171018010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.0 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.0.beta.20171017010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.0.beta.20171016010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.0.beta.20171015010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.0.beta.20171014010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.0.beta.20171011010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.0.beta.20171010010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.61.0 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.61.0.beta.20171009010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.61.0.beta.20171008010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.61.0.beta.20171007010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.61.0.beta.20171006010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.61.0.beta.20171005010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.61.0.beta.20171004010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.60.1 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.60.0 spaceship/lib/spaceship/tunes/member.rb