Class: Jamf::AppStoreCountryCodes
- Inherits:
-
SingletonResource
- Object
- JSONObject
- Resource
- SingletonResource
- Jamf::AppStoreCountryCodes
- Extended by:
- Immutable
- Defined in:
- lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb
Overview
The API endpoint for country codes.
Probably more useful is the Jamf.app_store_country_codes method which parses this into a hash of Code => Name
Constant Summary collapse
- RSRC_VERSION =
Constants
'v1'.freeze
- RSRC_PATH =
'app-store-country-codes'.freeze
- OBJECT_MODEL =
{ # @!attribute checkInFrequency # @return [integer] countryCodes: { class: Jamf::Country, multi: true, read_only: true, aliases: [:list] } }.freeze
Class Method Summary collapse
-
.code_for_name(name, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #code_for_name.
-
.codes(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #codes.
-
.codes_by_name(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #codes_by_name.
-
.list(refresh = false, cnx: Jamf.cnx) ⇒ Array<Jamf::Country>
All the Countries available.
- .mutable? ⇒ Boolean extended from Immutable
-
.name_for_code(code, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #name_for_code.
-
.names(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #names.
-
.names_by_code(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #names_by_code.
Instance Method Summary collapse
-
#code_for_name(name) ⇒ String
return a country code from its name, case-insensitive.
-
#codes ⇒ Array<String>
The available country codes.
-
#codes_by_name ⇒ Hash
Name => code.
-
#name_for_code(code) ⇒ String
return a country name from its code, case-insensitive.
-
#names ⇒ Array<String>
The available country names.
-
#names_by_code ⇒ Hash
Code => name.
Constructor Details
This class inherits a constructor from Jamf::JSONObject
Class Method Details
.code_for_name(name, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #code_for_name
92 93 94 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 92 def self.code_for_name(name, refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).code_for_name name end |
.codes(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #codes
77 78 79 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 77 def self.codes(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).codes end |
.codes_by_name(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #codes_by_name
82 83 84 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 82 def self.codes_by_name(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).codes_by_name end |
.list(refresh = false, cnx: Jamf.cnx) ⇒ Array<Jamf::Country>
Returns all the Countries available.
67 68 69 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 67 def self.list(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).countryCodes end |
.mutable? ⇒ Boolean Originally defined in module Immutable
.name_for_code(code, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #name_for_code
97 98 99 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 97 def self.name_for_code(code, refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).name_for_code code end |
Instance Method Details
#code_for_name(name) ⇒ String
return a country code from its name, case-insensitive
127 128 129 130 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 127 def code_for_name(name) name = names.select { |n| n.casecmp? name }.first codes_by_name[name] end |
#codes ⇒ Array<String>
Returns the available country codes.
110 111 112 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 110 def codes @codes ||= countryCodes.map(&:code) end |
#codes_by_name ⇒ Hash
Returns name => code.
115 116 117 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 115 def codes_by_name @codes_by_name ||= countryCodes.map { |country| [country.name, country.code] }.to_h end |
#name_for_code(code) ⇒ String
return a country name from its code, case-insensitive
135 136 137 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 135 def name_for_code(code) names_by_code[code.upcase] end |
#names ⇒ Array<String>
Returns the available country names.
105 106 107 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 105 def names @names ||= countryCodes.map(&:name) end |
#names_by_code ⇒ Hash
Returns code => name.
120 121 122 |
# File 'lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb', line 120 def names_by_code @names_by_code ||= countryCodes.map { |country| [country.code, country.name] }.to_h end |