effective_learndash 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/effective/learndash_api.rb +10 -13
- data/lib/effective_learndash/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 47f234d26d444d3ba71d72409db15186e4b1db00e1bf3c6aa007853143307265
         | 
| 4 | 
            +
              data.tar.gz: d97eea26d3a6cce1d8df2f154b06b8dbc558e8df8c731fdbff268185cb3d465c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 6aeaa81878fe93276c6bcdc366ec2f61f1fdc5ee952a6b9328890387619605ddb7883210765f203bef8ae053065c781eb59c109b084b06d164be079ebe7689b8
         | 
| 7 | 
            +
              data.tar.gz: 2d53168beee83ee8766389eaec11b48f6208e97e202d63ba3155f85278357b673ff1fab06de53cf9e8570fb57397ed5cf4cbfb4a2500a870c42691512fe061b8
         | 
| @@ -30,7 +30,7 @@ module Effective | |
| 30 30 | 
             
                def find_user(value)
         | 
| 31 31 | 
             
                  # Find by email
         | 
| 32 32 | 
             
                  if value.kind_of?(String) && value.include?('@')
         | 
| 33 | 
            -
                    return find_by("/wp/v2/users", :email, value)
         | 
| 33 | 
            +
                    return find_by("/wp/v2/users", :email, email_for(value))
         | 
| 34 34 | 
             
                  end
         | 
| 35 35 |  | 
| 36 36 | 
             
                  # Fetch by saved param value
         | 
| @@ -39,7 +39,7 @@ module Effective | |
| 39 39 | 
             
                  return user if user.present?
         | 
| 40 40 |  | 
| 41 41 | 
             
                  # Find by email
         | 
| 42 | 
            -
                  email = value | 
| 42 | 
            +
                  email = email_for(value)
         | 
| 43 43 | 
             
                  user = find_by("/wp/v2/users", :email, email) if email
         | 
| 44 44 | 
             
                  return user if user.present?
         | 
| 45 45 |  | 
| @@ -122,7 +122,6 @@ module Effective | |
| 122 122 |  | 
| 123 123 | 
             
                # private under this point
         | 
| 124 124 |  | 
| 125 | 
            -
             | 
| 126 125 | 
             
                def user_id(resource)
         | 
| 127 126 | 
             
                  if resource.class.respond_to?(:effective_learndash_owner?) # This is a user
         | 
| 128 127 | 
             
                    resource.learndash_user&.user_id
         | 
| @@ -147,18 +146,9 @@ module Effective | |
| 147 146 |  | 
| 148 147 | 
             
                def username_for(resource)
         | 
| 149 148 | 
             
                  raise('expected a LearnDash owner') unless resource.class.respond_to?(:effective_learndash_owner?) # This is a user
         | 
| 150 | 
            -
             | 
| 151 149 | 
             
                  name = EffectiveLearndash.wp_username_for(resource)
         | 
| 152 | 
            -
                  name = "test#{name}" unless Rails.env.production?
         | 
| 153 | 
            -
                  name
         | 
| 154 | 
            -
                end
         | 
| 155 | 
            -
             | 
| 156 | 
            -
                def email_for(resource)
         | 
| 157 | 
            -
                  raise('expected a LearnDash owner') unless resource.class.respond_to?(:effective_learndash_owner?) # This is a user
         | 
| 158 150 |  | 
| 159 | 
            -
                   | 
| 160 | 
            -
                  email = "test#{email}" unless Rails.env.production?
         | 
| 161 | 
            -
                  email
         | 
| 151 | 
            +
                  Rails.env.production? ? name : "test#{name}"
         | 
| 162 152 | 
             
                end
         | 
| 163 153 |  | 
| 164 154 | 
             
                def password_for(resource)
         | 
| @@ -166,6 +156,13 @@ module Effective | |
| 166 156 | 
             
                  EffectiveLearndash.wp_password_for(resource)
         | 
| 167 157 | 
             
                end
         | 
| 168 158 |  | 
| 159 | 
            +
                def email_for(value)
         | 
| 160 | 
            +
                  email = value.try(:email) || value.to_s
         | 
| 161 | 
            +
                  return nil unless email.present? && email.include?('@')
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                  Rails.env.production? ? email : "test#{email}"
         | 
| 164 | 
            +
                end
         | 
| 165 | 
            +
             | 
| 169 166 | 
             
                def find(endpoint, params = nil)
         | 
| 170 167 | 
             
                  response = get(endpoint, params)
         | 
| 171 168 |  |