Commit 0dd9fc8
Changed files (12)
lib
lib/scim/shady/builders/addresses.rb
@@ -0,0 +1,24 @@
+module Scim
+ module Shady
+ module Builders
+ class Addresses
+ def add(type:, street_address:, locality:, region:, postal_code:, country:, primary: false)
+ @items ||= []
+ @items.push(
+ type: type,
+ streetAddress: street_address,
+ locality: locality,
+ region: region,
+ postalCode: postal_code,
+ country: country,
+ primary: primary,
+ )
+ end
+
+ def to_h
+ { 'addresses' => @items }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders/emails.rb
@@ -0,0 +1,16 @@
+module Scim
+ module Shady
+ module Builders
+ class Emails
+ def add(email, type:, primary: false)
+ @items ||= []
+ @items.push(value: email, type: type, primary: primary)
+ end
+
+ def to_h
+ { 'emails' => @items }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders/groups.rb
@@ -0,0 +1,16 @@
+module Scim
+ module Shady
+ module Builders
+ class Groups
+ def add(id, url, display_name)
+ @items ||= []
+ @items.push(value: id, '$ref' => url, display: display_name)
+ end
+
+ def to_h
+ { 'groups' => @items }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders/instant_messengers.rb
@@ -0,0 +1,16 @@
+module Scim
+ module Shady
+ module Builders
+ class InstantMessengers
+ def add(handle, type:)
+ @items ||= []
+ @items.push(value: handle, type: type)
+ end
+
+ def to_h
+ { 'ims' => @items }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders/name.rb
@@ -0,0 +1,27 @@
+module Scim
+ module Shady
+ module Builders
+ class Name
+ attr_accessor :family_name
+ attr_accessor :given_name
+ attr_accessor :middle_name
+ attr_accessor :honorific_prefix
+ attr_accessor :honorific_suffix
+ attr_accessor :formatted
+
+ def to_h
+ {
+ 'name' => {
+ 'formatted' => formatted,
+ 'familyName' => family_name,
+ 'givenName' => given_name,
+ 'middleName' => middle_name,
+ 'honorificPrefix' => honorific_prefix,
+ 'honorificSuffix' => honorific_suffix,
+ }
+ }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders/phone_numbers.rb
@@ -0,0 +1,16 @@
+module Scim
+ module Shady
+ module Builders
+ class PhoneNumbers
+ def add(phone_number, type: :work)
+ @items ||= []
+ @items.push(value: phone_number, type: type)
+ end
+
+ def to_h
+ { 'phoneNumbers' => @items }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders/photos.rb
@@ -0,0 +1,16 @@
+module Scim
+ module Shady
+ module Builders
+ class Photos
+ def add(url, type: :photo)
+ @items ||= []
+ @items.push(value: url, type: type)
+ end
+
+ def to_h
+ { 'photos' => @items }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders/resource.rb
@@ -1,5 +1,3 @@
-require 'forwardable'
-
module Scim
module Shady
module Builders
lib/scim/shady/builders/user.rb
@@ -91,113 +91,6 @@ module Scim
.merge(@x509_certificates.to_h)
end
end
-
- class Name
- attr_accessor :family_name
- attr_accessor :given_name
- attr_accessor :middle_name
- attr_accessor :honorific_prefix
- attr_accessor :honorific_suffix
- attr_accessor :formatted
-
- def to_h
- {
- 'name' => {
- 'formatted' => formatted,
- 'familyName' => family_name,
- 'givenName' => given_name,
- 'middleName' => middle_name,
- 'honorificPrefix' => honorific_prefix,
- 'honorificSuffix' => honorific_suffix,
- }
- }
- end
- end
-
- class Emails
- def add(email, type:, primary: false)
- @items ||= []
- @items.push(value: email, type: type, primary: primary)
- end
-
- def to_h
- { 'emails' => @items }
- end
- end
-
- class Addresses
- def add(type:, street_address:, locality:, region:, postal_code:, country:, primary: false)
- @items ||= []
- @items.push(
- type: type,
- streetAddress: street_address,
- locality: locality,
- region: region,
- postalCode: postal_code,
- country: country,
- primary: primary,
- )
- end
-
- def to_h
- { 'addresses' => @items }
- end
- end
-
- class PhoneNumbers
- def add(phone_number, type: :work)
- @items ||= []
- @items.push(value: phone_number, type: type)
- end
-
- def to_h
- { 'phoneNumbers' => @items }
- end
- end
-
- class InstantMessengers
- def add(handle, type:)
- @items ||= []
- @items.push(value: handle, type: type)
- end
-
- def to_h
- { 'ims' => @items }
- end
- end
-
- class Photos
- def add(url, type: :photo)
- @items ||= []
- @items.push(value: url, type: type)
- end
-
- def to_h
- { 'photos' => @items }
- end
- end
-
- class Groups
- def add(id, url, display_name)
- @items ||= []
- @items.push(value: id, '$ref' => url, display: display_name)
- end
-
- def to_h
- { 'groups' => @items }
- end
- end
-
- class X509Certificates
- def add(certificate)
- @items ||= []
- @items.push(value: certificate.to_pem.gsub(/-----BEGIN CERTIFICATE-----/, '').gsub(/-----END CERTIFICATE-----/, ''))
- end
-
- def to_h
- { 'x509Certificates' => @items }
- end
- end
end
end
end
lib/scim/shady/builders/x509_certificates.rb
@@ -0,0 +1,16 @@
+module Scim
+ module Shady
+ module Builders
+ class X509Certificates
+ def add(certificate)
+ @items ||= []
+ @items.push(value: certificate.to_pem.gsub(/-----BEGIN CERTIFICATE-----/, '').gsub(/-----END CERTIFICATE-----/, ''))
+ end
+
+ def to_h
+ { 'x509Certificates' => @items }
+ end
+ end
+ end
+ end
+end
lib/scim/shady/builders.rb
@@ -1,4 +1,12 @@
+require "scim/shady/builders/addresses"
+require "scim/shady/builders/emails"
+require "scim/shady/builders/groups"
+require "scim/shady/builders/instant_messengers"
require "scim/shady/builders/metadata"
+require "scim/shady/builders/name"
+require "scim/shady/builders/phone_numbers"
+require "scim/shady/builders/photos"
require "scim/shady/builders/resource"
require "scim/shady/builders/service_provider_configuration"
require "scim/shady/builders/user"
+require "scim/shady/builders/x509_certificates"
lib/scim/shady.rb
@@ -1,3 +1,4 @@
+require "forwardable"
require "json"
require "time"