dipps-client 0.3.0 → 0.5.0
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/lib/dipps/client/error.rb +6 -0
 - data/lib/dipps/client/queries/clients.rb +3 -2
 - data/lib/dipps/client/version.rb +1 -1
 - data/lib/dipps/client.rb +30 -14
 - data/vendor/schema.json +1348 -556
 - metadata +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f55122ca9cde052f4927804ebab6419948025d45d1b1f3c6ad16c457968977a9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0236e9bad74ea19f3906264f5bf62216e2aa9ca0b38cb84ffa551d28e7a33322
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8b40c5cd5a3272b91938360a36fd4eb26116b2b80966f0a33f236287999d162979af0e55eae7a8154bfb7734990edddcaa8df0ec5545c7fc632bd096d1185882
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fea5eabf78ba9cb518a367c0112a8349bec52157e79d771c7f9710c90e1c3d4dcc18268f0ef9307081939bf1acec958ed4100ccfa8cd572abd9a13853ee8d9f9
         
     | 
| 
         @@ -2,10 +2,11 @@ module Dipps 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Client
         
     | 
| 
       3 
3 
     | 
    
         
             
                module Queries
         
     | 
| 
       4 
4 
     | 
    
         
             
                  Clients = GraphqlClient.parse <<~GQL
         
     | 
| 
       5 
     | 
    
         
            -
                    query($orgNumber: String, $email: String) {
         
     | 
| 
      
 5 
     | 
    
         
            +
                    query($orgNumber: String, $email: String, $freelance_profile_id: ID!) {
         
     | 
| 
       6 
6 
     | 
    
         
             
                      clients(
         
     | 
| 
       7 
7 
     | 
    
         
             
                        orgNumber: $orgNumber,
         
     | 
| 
       8 
     | 
    
         
            -
                        email: $email
         
     | 
| 
      
 8 
     | 
    
         
            +
                        email: $email,
         
     | 
| 
      
 9 
     | 
    
         
            +
                        freelanceProfileId: $freelance_profile_id
         
     | 
| 
       9 
10 
     | 
    
         
             
                      ) {
         
     | 
| 
       10 
11 
     | 
    
         
             
                        id
         
     | 
| 
       11 
12 
     | 
    
         
             
                        clientType
         
     | 
    
        data/lib/dipps/client/version.rb
    CHANGED
    
    
    
        data/lib/dipps/client.rb
    CHANGED
    
    | 
         @@ -2,6 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require_relative 'client/version'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require_relative 'client/configuration'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative 'client/error'
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            module Dipps
         
     | 
| 
       7 
8 
     | 
    
         
             
              module Client
         
     | 
| 
         @@ -22,43 +23,58 @@ module Dipps 
     | 
|
| 
       22 
23 
     | 
    
         
             
                    @configuration ||= Dipps::Client::Configuration.new
         
     | 
| 
       23 
24 
     | 
    
         
             
                  end
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
      
 26 
     | 
    
         
            +
                  def perform_query(query:, result_field:, variables: {})
         
     | 
| 
      
 27 
     | 
    
         
            +
                    result = GraphqlClient.query(query, variables: variables)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                    if result.errors.any?
         
     | 
| 
      
 30 
     | 
    
         
            +
                      raise(Dipps::Client::Error, result.errors.details.inspect)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    result.data.to_h.fetch(result_field)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       25 
36 
     | 
    
         
             
                  def create_own_invoice(freelance_profile_id:, attributes:)
         
     | 
| 
       26 
     | 
    
         
            -
                     
     | 
| 
       27 
     | 
    
         
            -
                      Dipps::Client::Queries::CreateOwnInvoice,
         
     | 
| 
      
 37 
     | 
    
         
            +
                    perform_query(
         
     | 
| 
      
 38 
     | 
    
         
            +
                      query: Dipps::Client::Queries::CreateOwnInvoice,
         
     | 
| 
      
 39 
     | 
    
         
            +
                      result_field: 'createOwnInvoice',
         
     | 
| 
       28 
40 
     | 
    
         
             
                      variables: {
         
     | 
| 
       29 
41 
     | 
    
         
             
                        freelance_profile_id: freelance_profile_id,
         
     | 
| 
       30 
42 
     | 
    
         
             
                        attributes: attributes
         
     | 
| 
       31 
43 
     | 
    
         
             
                      }
         
     | 
| 
       32 
     | 
    
         
            -
                    ) 
     | 
| 
      
 44 
     | 
    
         
            +
                    )
         
     | 
| 
       33 
45 
     | 
    
         
             
                  end
         
     | 
| 
       34 
46 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                  def clients(org_number: nil, email: nil)
         
     | 
| 
       36 
     | 
    
         
            -
                     
     | 
| 
       37 
     | 
    
         
            -
                      Dipps::Client::Queries::Clients,
         
     | 
| 
      
 47 
     | 
    
         
            +
                  def clients(freelance_profile_id:, org_number: nil, email: nil)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    perform_query(
         
     | 
| 
      
 49 
     | 
    
         
            +
                      query: Dipps::Client::Queries::Clients,
         
     | 
| 
      
 50 
     | 
    
         
            +
                      result_field: 'clients',
         
     | 
| 
       38 
51 
     | 
    
         
             
                      variables: {
         
     | 
| 
       39 
52 
     | 
    
         
             
                        orgNumber: org_number,
         
     | 
| 
       40 
     | 
    
         
            -
                        email: email
         
     | 
| 
      
 53 
     | 
    
         
            +
                        email: email,
         
     | 
| 
      
 54 
     | 
    
         
            +
                        freelance_profile_id: freelance_profile_id
         
     | 
| 
       41 
55 
     | 
    
         
             
                      }
         
     | 
| 
       42 
     | 
    
         
            -
                    ) 
     | 
| 
      
 56 
     | 
    
         
            +
                    )
         
     | 
| 
       43 
57 
     | 
    
         
             
                  end
         
     | 
| 
       44 
58 
     | 
    
         | 
| 
       45 
59 
     | 
    
         
             
                  def create_client(attributes:)
         
     | 
| 
       46 
     | 
    
         
            -
                     
     | 
| 
       47 
     | 
    
         
            -
                      Dipps::Client::Queries::CreateClient,
         
     | 
| 
      
 60 
     | 
    
         
            +
                    perform_query(
         
     | 
| 
      
 61 
     | 
    
         
            +
                      query: Dipps::Client::Queries::CreateClient,
         
     | 
| 
      
 62 
     | 
    
         
            +
                      result_field: 'createClient',
         
     | 
| 
       48 
63 
     | 
    
         
             
                      variables: {
         
     | 
| 
       49 
64 
     | 
    
         
             
                        attributes: attributes
         
     | 
| 
       50 
65 
     | 
    
         
             
                      }
         
     | 
| 
       51 
     | 
    
         
            -
                    ) 
     | 
| 
      
 66 
     | 
    
         
            +
                    )
         
     | 
| 
       52 
67 
     | 
    
         
             
                  end
         
     | 
| 
       53 
68 
     | 
    
         | 
| 
       54 
69 
     | 
    
         
             
                  def update_client(id:, attributes:)
         
     | 
| 
       55 
     | 
    
         
            -
                     
     | 
| 
       56 
     | 
    
         
            -
                      Dipps::Client::Queries::UpdateClient,
         
     | 
| 
      
 70 
     | 
    
         
            +
                    perform_query(
         
     | 
| 
      
 71 
     | 
    
         
            +
                      query: Dipps::Client::Queries::UpdateClient,
         
     | 
| 
      
 72 
     | 
    
         
            +
                      result_field: 'updateClient',
         
     | 
| 
       57 
73 
     | 
    
         
             
                      variables: {
         
     | 
| 
       58 
74 
     | 
    
         
             
                        id: id,
         
     | 
| 
       59 
75 
     | 
    
         
             
                        attributes: attributes
         
     | 
| 
       60 
76 
     | 
    
         
             
                      }
         
     | 
| 
       61 
     | 
    
         
            -
                    ) 
     | 
| 
      
 77 
     | 
    
         
            +
                    )
         
     | 
| 
       62 
78 
     | 
    
         
             
                  end
         
     | 
| 
       63 
79 
     | 
    
         
             
                end
         
     | 
| 
       64 
80 
     | 
    
         
             
              end
         
     |