dscf-marketplace 0.2.1 → 0.2.2
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
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b03c9932cc3e31e46ea8ac2689f410b4f78b0cd950340a780b52e67abba8693c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cef9643cb87044521d76d31f930affdeb899cc35a7ab67f9f129b346fd05dfdf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cd00154351d1e038a1f375c2016db715d75ddb8808f8a1e30cebb234eb1f25f4dbaa160bdd8446b897a8542a08f064bee63b89e981dc36b05bd589b2638c4533
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c0f0e1b6c4fb9f5dcc8f1bd442058fc9494f0366819e0561ef228141755e3870217ff8512052894857655c55657114c395dd69aa5e84d77f6163bbd42db01395
         
     | 
| 
         @@ -8,25 +8,49 @@ module Dscf 
     | 
|
| 
       8 
8 
     | 
    
         
             
                    render_success("business.success.has_business_check", data: {has_business: has_business})
         
     | 
| 
       9 
9 
     | 
    
         
             
                  end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
                  def create
         
     | 
| 
      
 12 
     | 
    
         
            +
                    business = @clazz.new(model_params.except(:business_license))
         
     | 
| 
      
 13 
     | 
    
         
            +
                    if business.save
         
     | 
| 
      
 14 
     | 
    
         
            +
                      # Add document upload after save
         
     | 
| 
      
 15 
     | 
    
         
            +
                      if params[:business][:business_license].present?
         
     | 
| 
      
 16 
     | 
    
         
            +
                        document = Dscf::Core::Document.new(
         
     | 
| 
      
 17 
     | 
    
         
            +
                          documentable: business,
         
     | 
| 
      
 18 
     | 
    
         
            +
                          document_type: :business_license
         
     | 
| 
      
 19 
     | 
    
         
            +
                        )
         
     | 
| 
      
 20 
     | 
    
         
            +
                        document.file.attach(params[:business][:business_license])
         
     | 
| 
      
 21 
     | 
    
         
            +
                        document.save!
         
     | 
| 
      
 22 
     | 
    
         
            +
                      end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                      business = @clazz.includes(eager_loaded_associations).find(business.id) if eager_loaded_associations.present?
         
     | 
| 
      
 25 
     | 
    
         
            +
                      includes = serializer_includes_for_action(:create)
         
     | 
| 
      
 26 
     | 
    
         
            +
                      options = {include: includes} if includes.present?
         
     | 
| 
      
 27 
     | 
    
         
            +
                      render_success(data: business, serializer_options: options, status: :created)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    else
         
     | 
| 
      
 29 
     | 
    
         
            +
                      render_error(errors: business.errors.full_messages[0], status: :unprocessable_entity)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  rescue => e
         
     | 
| 
      
 32 
     | 
    
         
            +
                    render_error(error: e.message)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       11 
35 
     | 
    
         
             
                  private
         
     | 
| 
       12 
36 
     | 
    
         | 
| 
       13 
37 
     | 
    
         
             
                  def model_params
         
     | 
| 
       14 
38 
     | 
    
         
             
                    params.require(:business).permit(
         
     | 
| 
       15 
39 
     | 
    
         
             
                      :name, :description, :contact_email, :contact_phone, :tin_number,
         
     | 
| 
       16 
     | 
    
         
            -
                      :business_type_id, :user_id
         
     | 
| 
      
 40 
     | 
    
         
            +
                      :business_type_id, :user_id, business_license: :file
         
     | 
| 
       17 
41 
     | 
    
         
             
                    )
         
     | 
| 
       18 
42 
     | 
    
         
             
                  end
         
     | 
| 
       19 
43 
     | 
    
         | 
| 
       20 
44 
     | 
    
         
             
                  def eager_loaded_associations
         
     | 
| 
       21 
     | 
    
         
            -
                    [ :business_type, :user ]
         
     | 
| 
      
 45 
     | 
    
         
            +
                    [ :business_type, :user, :documents ]
         
     | 
| 
       22 
46 
     | 
    
         
             
                  end
         
     | 
| 
       23 
47 
     | 
    
         | 
| 
       24 
48 
     | 
    
         
             
                  def default_serializer_includes
         
     | 
| 
       25 
49 
     | 
    
         
             
                    {
         
     | 
| 
       26 
     | 
    
         
            -
                      index: [ :business_type, :user ],
         
     | 
| 
       27 
     | 
    
         
            -
                      show: [ :business_type, :user ],
         
     | 
| 
       28 
     | 
    
         
            -
                      create: [ :business_type, :user ],
         
     | 
| 
       29 
     | 
    
         
            -
                      update: [ :business_type, :user ]
         
     | 
| 
      
 50 
     | 
    
         
            +
                      index: [ :business_type, :user, :documents ],
         
     | 
| 
      
 51 
     | 
    
         
            +
                      show: [ :business_type, :user, :documents ],
         
     | 
| 
      
 52 
     | 
    
         
            +
                      create: [ :business_type, :user, :documents ],
         
     | 
| 
      
 53 
     | 
    
         
            +
                      update: [ :business_type, :user, :documents ]
         
     | 
| 
       30 
54 
     | 
    
         
             
                    }
         
     | 
| 
       31 
55 
     | 
    
         
             
                  end
         
     | 
| 
       32 
56 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dscf-marketplace
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Asrat
         
     | 
| 
         @@ -456,6 +456,7 @@ files: 
     | 
|
| 
       456 
456 
     | 
    
         
             
            - app/serializers/dscf/marketplace/delivery_order_item_serializer.rb
         
     | 
| 
       457 
457 
     | 
    
         
             
            - app/serializers/dscf/marketplace/delivery_order_serializer.rb
         
     | 
| 
       458 
458 
     | 
    
         
             
            - app/serializers/dscf/marketplace/delivery_vehicle_serializer.rb
         
     | 
| 
      
 459 
     | 
    
         
            +
            - app/serializers/dscf/marketplace/document_serializer.rb
         
     | 
| 
       459 
460 
     | 
    
         
             
            - app/serializers/dscf/marketplace/listing_serializer.rb
         
     | 
| 
       460 
461 
     | 
    
         
             
            - app/serializers/dscf/marketplace/order_item_serializer.rb
         
     | 
| 
       461 
462 
     | 
    
         
             
            - app/serializers/dscf/marketplace/order_serializer.rb
         
     |