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.65.0.beta.20171107010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.64.0 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.64.0.beta.20171106010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.64.0.beta.20171105010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.64.0.beta.20171104010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.64.0.beta.20171103010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.64.0.beta.20171102010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.64.0.beta.20171101010004 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171031010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171030010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171029010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171028010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171027010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171026010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171025010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171024010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.62.1 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171023010003 spaceship/lib/spaceship/tunes/member.rb
fastlane-2.63.0.beta.20171022010003 spaceship/lib/spaceship/tunes/member.rb