gandirb 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 2.1.1
2
+
3
+ * Set XMLRPC::Config::ENABLE_NIL_PARSER to avoid XML-RPC nil errors with Ruby 1.9.2. (Github issue #1)
4
+
1
5
  == 2.1.0
2
6
 
3
7
  * Zone classes and methods
@@ -1,6 +1,11 @@
1
1
  require 'xmlrpc/client'
2
2
  require 'openssl'
3
3
 
4
+ XMLRPC::Config.module_eval { # avoid "RuntimeError: wrong/unknown XML-RPC type 'nil'" using Ruby 1.9
5
+ remove_const(:ENABLE_NIL_PARSER)
6
+ const_set(:ENABLE_NIL_PARSER, true)
7
+ }
8
+
4
9
  module Gandi
5
10
  class Connection
6
11
  SSL_VERIFY_MODE = OpenSSL::SSL::VERIFY_NONE
data/lib/gandi/contact.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Gandi
4
4
  class Contact
5
5
  include Gandi::GandiObjectMethods
6
-
6
+
7
7
  #Contact types mapping
8
8
  TYPES = {
9
9
  0 => 'person',
@@ -12,7 +12,7 @@ module Gandi
12
12
  3 => 'organization',
13
13
  4 => 'reseller'
14
14
  }
15
-
15
+
16
16
  #Security questions mapping
17
17
  SECURITY_QUESTION_NUM_VALUES = {
18
18
  1 => "What is the name of your favorite city?",
@@ -22,22 +22,22 @@ module Gandi
22
22
  5 => "What is your cell phone number?",
23
23
  6 => "In what year was your Gandi account created?"
24
24
  }
25
-
25
+
26
26
  #Settable contact attributes (ie. not the id or handle)
27
- WRITABLE_ATTRIBUTES = :type, :orgname, :given, :family, :streetaddr, :city, :state, :zip, :country, :phone, :fax, :mobile,
28
- :tva_number, :siren, :marque, :lang, :newsletter, :obfuscated, :whois_obfuscated, :resell, :shippingaddress,
27
+ WRITABLE_ATTRIBUTES = :type, :orgname, :given, :family, :streetaddr, :city, :state, :zip, :country, :phone, :fax, :mobile,
28
+ :tva_number, :siren, :marque, :lang, :newsletter, :obfuscated, :whois_obfuscated, :resell, :shippingaddress,
29
29
  :extra_parameters
30
-
30
+
31
31
  #Additional attributes used when creating an account
32
- CREATE_PARAMETERS_ATTRIBUTES = :password, :email,
32
+ CREATE_PARAMETERS_ATTRIBUTES = :password, :email,
33
33
  :jo_announce_page, :jo_announce_number, :jo_declaration_date, :jo_publication_date,
34
34
  :security_question_num, :security_question_answer
35
-
35
+
36
36
  #Attributes returned when calling contact.info or creating/updating a contact
37
37
  INFORMATION_ATTRIBUTES = WRITABLE_ATTRIBUTES + [:id]
38
-
38
+
39
39
  attr_reader :handle
40
-
40
+
41
41
  #A new instance of Contact.
42
42
  #Takes a Gandi handle and/or a contact hash with string keys.
43
43
  #When providing only a handle the contact info will be fetched from the API.
@@ -46,7 +46,7 @@ module Gandi
46
46
  @attributes = {}
47
47
  self.attributes=(contact) if (@handle || contact)
48
48
  end
49
-
49
+
50
50
  #Test if a contact (defined by its handle) can create that domain.
51
51
  #Takes a domain hash.
52
52
  #TODO allow giving a string for the domain and converting it transparently, or a domain object.
@@ -56,65 +56,65 @@ module Gandi
56
56
  return false unless persisted?
57
57
  self.class.call('contact.can_associate_domain', @handle, domain)
58
58
  end
59
-
59
+
60
60
  #TODO make this method return a boolean
61
61
  alias_method :can_associate_domain?, :can_associate_domain
62
-
62
+
63
63
  #Give all information on the given contact.
64
64
  #This should not be directly used as initializing the class already fetches the contact info.
65
65
  def info
66
66
  raise DataError, "Cannot get informations for a new contact" unless persisted?
67
67
  self.class.call('contact.info', @handle)
68
68
  end
69
-
70
- #Check the same way as check and then update.
71
- #FIXME What is check ? Typo for create ?
69
+
70
+ #Update a contact with the given information.
71
+ #If the contact is associated to domains, it will check the same rules as can_associate* and then update if possible.
72
72
  def update(contact)
73
73
  raise DataError, "Cannot update a new contact, use Gandi::Contact.create instead" unless persisted?
74
74
  self.attributes = self.class.call('contact.update', @handle, contact)
75
75
  end
76
-
76
+
77
77
  (WRITABLE_ATTRIBUTES - [:type]).each do |attr|
78
78
  define_method(attr) do
79
79
  @attributes[attr.to_s]
80
80
  end
81
-
81
+
82
82
  define_method("#{attr}=") do |value|
83
83
  @attributes[attr.to_s] = value
84
84
  end
85
85
  end
86
-
86
+
87
87
  #Returns the contact unique identifier.
88
88
  def id
89
89
  @attributes['id']
90
90
  end
91
-
91
+
92
92
  #Returns the contact type string.
93
93
  def type
94
94
  TYPES[@attributes['type']]
95
95
  end
96
-
96
+
97
97
  #Sets the contact type (provided with a type string or id).
98
98
  def type=(type_string_or_id)
99
99
  @attributes['type'] = TYPES.invert[type_string_or_id] || type_string_or_id
100
100
  end
101
-
101
+
102
102
  #Sets a contact attribute value.
103
103
  def []=(attribute, value)
104
104
  raise DataError, "Attribute #{attribute} is read-only" unless WRITABLE_ATTRIBUTES.include?(attribute.to_sym)
105
105
  @attributes[attribute.to_s] = value
106
106
  end
107
-
107
+
108
108
  #Returns a string containing the handle of the contact.
109
109
  def to_s
110
110
  @handle || ''
111
111
  end
112
-
112
+
113
113
  #Returns true if the contact exists on Gandi databases.
114
114
  def persisted?
115
115
  !!@handle
116
116
  end
117
-
117
+
118
118
  class << self
119
119
  #Should have a all optional contact dict then look if he is a person or a company and depending on that call create_person or create_company.
120
120
  #Returns a contact object.
@@ -123,13 +123,13 @@ module Gandi
123
123
  contact = call('contact.create', contact)
124
124
  self.new(contact['handle'], contact)
125
125
  end
126
-
126
+
127
127
  #Give all information on the contact linked to the apikey currently used.
128
128
  #Returns a hash.
129
129
  def info
130
130
  call('contact.info')
131
131
  end
132
-
132
+
133
133
  #Test if a contact (full contact description) can be associated to the domains.
134
134
  #Takes a contact hash and a domain hash.
135
135
  #TODO allow giving a string for the domain and converting it transparently, or a domain object.
@@ -138,10 +138,10 @@ module Gandi
138
138
  def can_associate(contact, domain)
139
139
  call('contact.can_associate', contact, domain)
140
140
  end
141
-
141
+
142
142
  #TODO make this method return a boolean
143
143
  alias_method :can_associate?, :can_associate
144
-
144
+
145
145
  #List all contacts linked to the connected user (it will only return contacts when the apikey belong to a reseller).
146
146
  #The array of returned contacts are mapped to contact objects, set map_contacts to false to get contact info hashes.
147
147
  def list(opts = {}, map_contacts = true)
@@ -153,7 +153,7 @@ module Gandi
153
153
  end
154
154
  contacts
155
155
  end
156
-
156
+
157
157
  #Check the same way as check and then update.
158
158
  #Returns a contact object.
159
159
  #TODO filter params.
@@ -162,9 +162,9 @@ module Gandi
162
162
  self.new(contact['handle'], contact)
163
163
  end
164
164
  end
165
-
165
+
166
166
  private
167
-
167
+
168
168
  def attributes=(contact = nil)
169
169
  contact_attributes = contact || info
170
170
  @attributes = contact_attributes.reject {|k,v| !INFORMATION_ATTRIBUTES.include?(k.to_sym) }
data/lib/gandi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gandi
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gandirb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-28 00:00:00.000000000Z
12
+ date: 2012-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &74003420 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *74003420
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rdoc
27
- requirement: &74003150 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *74003150
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &74002840 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: '2.8'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *74002840
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '2.8'
47
62
  description: ! " A Ruby library for using the Gandi XML-RPC API.\n At the moment
48
63
  support is planned for the Domain, Contact and Operation APIs only, but Hosting
49
64
  and Catalog APIs support may be added in the future.\n"
@@ -125,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
140
  version: '0'
126
141
  requirements: []
127
142
  rubyforge_project: gandirb
128
- rubygems_version: 1.8.10
143
+ rubygems_version: 1.8.24
129
144
  signing_key:
130
145
  specification_version: 3
131
146
  summary: Ruby library for using the Gandi XML-RPC API